Jul 14, 2026

Upload Internal Table to Application Server (AL11) in CSV format Using Class CL_RSDA_CSV_CONVERTER, Method STRUCTURE_TO_CSV

Here is another way to upload internal table to Application Server into CSV format.  
And upload using statement OPEN DATASET.

  DATA: lt_csv_format TYPE truxs_t_text_data, " Standard table type for text
        lv_filepath   TYPE string,
        lv_csv_line   TYPE string.    

  " .... Assuming GT_CSV already populated.

  " Convert internal table to CSV structure
  DATA: lv_c4096 TYPE c LENGTH 4096.
  DATA(lo_csv) = cl_rsda_csv_converter=>create( ).

  " Covert line by line item
  LOOP AT gt_csv ASSIGNING FIELD-SYMBOL(<ls_csv>).
    CLEAR lv_c4096.
    lo_csv->structure_to_csv( EXPORTING i_s_data = <ls_csv>
                              IMPORTING e_data   = lv_c4096 ).
    APPEND INITIAL LINE TO lt_csv_format ASSIGNING FIELD-SYMBOL(<ls_csv_format>).
    IF sy-subrc EQ 0.
      <ls_csv_format> = lv_c4096.
    ENDIF.
  ENDLOOP.

  IF sy-subrc = 0.

    " Write to Application Server
    OPEN DATASET lv_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc = 0.
      LOOP AT lt_csv_format INTO lv_csv_line.
        TRANSFER lv_csv_line TO lv_filepath.
      ENDLOOP.
      CLOSE DATASET lv_filepath.
    ENDIF.

  ENDIF.

Jul 13, 2026

Remove Leading Zero of a Field in CDS (ADT)

Example: Field QAPP.PPSORTKEY



Original Code
      /*-- Sample / Inspection Point (from QAPP) ---------------------------*/
      qapp.probenr    as SampleInspectionPoint,
      qapp.ppsortkey, as InspectionPoint


The change, using ltrim (supported in CDS view entities):



New Code
      /*-- Sample / Inspection Point (from QAPP) ---------------------------*/
      qapp.probenr    as SampleInspectionPoint,
      ltrim( qapp.ppsortkey, '0' ) as InspectionPoint

Two notes on this:

  1. ltrim( field, '0' ) removes only leading '0' characters — an all-zero value becomes an empty string. If you'd rather show '0' in that case, wrap it: case when ltrim(...) = '' then '0' else ltrim(...) end. I didn't add that since you didn't ask.
  2. The result type stays character, same length — no dictionary impact, activation-safe. If the Fiori app later sorts or filters on InspectionPoint, remember it's now text-sorted without zero padding, so ordering across values of different lengths will look wrong ('12' before '3' is gone, but '3' now comes after '12' alphabetically... actually '12' < '3' as text). If sorting matters, keep the raw field as a hidden sort column.

Jul 6, 2026

Replace Some Characters in the Middle of Text.

Requirement:

To replace the 5th character in a 10-character string (or any string), use the ABAP overlay statement or the replace section command. In ABAP, character offsets are zero-based, meaning the 5th character is at offset

Solution:

Here are the two best approaches for doing this:

Method 1: Using OVERLAY (Best for replacing specific offsets)
abap
DATA: gv_string TYPE string VALUE '1234567890'.

" The 5th character is at offset 4 (length 1). Replace it with 'X'
OVERLAY gv_string WITH '    X' ONLY ' '.

Method 2: Using REPLACE SECTION (Best for explicit length)
abap
DATA: gv_string TYPE string VALUE '1234567890'.

REPLACE SECTION OFFSET 4 LENGTH 1 OF gv_string WITH 'X'.

Method 3: Inline Expression (ABAP 7.40+)
abap
DATA(gv_string) = '1234567890'.

gv_string = |{ gv_string(4) }X{ gv_string+5 }|.

Output for all methods: 1234X67890