Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

MODIFY statement in ALV issue

Hi Guys,

I am developing a ALV list report to display SO header and item texts.

In the below code- I face the this problem.

If header text in SO has 2 lines and item text has 5 lines, it prints only

2lines of item text.




*---Header Text
{code}

v_head_name = wa_out-vbeln.

     CALL FUNCTION 'READ_TEXT'
       EXPORTING
         id                      = 'ZOR5'
         language                = 'E'
         name                    = v_head_name
         object                  = 'VBBK'
       TABLES
         lines                   = gt_head_txt
     
     IF sy-subrc EQ 0.
       DELETE gt_head_txt WHERE tdline = ''.
       CLEAR : v_tabix , it_sentence_h.
       LOOP AT gt_head_txt INTO wa_head_txt.
         v_tabix = sy-tabix.
         CALL FUNCTION 'RKD_WORD_WRAP'
           EXPORTING
             textline            = wa_head_txt-tdline
             outputlen           = c_len
           TABLES
             out_lines           = it_sentence_h
           EXCEPTIONS
             outputlen_too_large = 1
             OTHERS              = 2.

         IF sy-subrc EQ 0.
           READ TABLE it_sentence_h INTO wa_word_h INDEX v_tabix.
           wa_out-htext = wa_word_h-text.
           IF v_tabix = 1.
             MOVE: v_head_name TO wa_so_head-vbeln.
           ENDIF.
           APPEND wa_out TO it_out.
           CLEAR: wa_out, wa_word_h.
         ENDIF.
       ENDLOOP.
     ENDIF.
   ENDLOOP.

*-- Item Text
   LOOP AT it_out INTO wa_out.
     CONCATENATE wa_out-vbeln wa_out-posnr INTO v_item_name.
     v_posnr = wa_out-posnr.
*--Plant Specific Instruction Text
     CALL FUNCTION 'READ_TEXT'
       EXPORTING
         id                      = 'ZPSI'
         language                = 'E'
         name                    = v_item_name
         object                  = 'VBBP'
       TABLES
         lines                   = gt_item_txt
      

     IF sy-subrc NE 0.
       lv_no = lv_no + 1.
     ENDIF.

     IF sy-subrc EQ 0.
       DELETE gt_item_txt WHERE tdline = ''.
*      AT NEW vbeln.
       CLEAR :it_sentence_i, v_tabix.
       LOOP AT gt_item_txt INTO wa_item_txt.
         lv_no = lv_no + 1.
         v_tabix = sy-tabix.
         IF v_tabix = 1.
           MOVE: v_item_name TO wa_get-vbeln,
                 v_posnr TO wa_get-posnr.
         ENDIF.

         CALL FUNCTION 'RKD_WORD_WRAP'
           EXPORTING
             textline            = wa_item_txt-tdline
             outputlen           = c_len
           TABLES
             out_lines           = it_sentence_i
           EXCEPTIONS
             outputlen_too_large = 1
             OTHERS              = 2.

         IF sy-subrc EQ 0.
           READ TABLE it_sentence_i INTO wa_word_i INDEX v_tabix.
           wa_out-ltext = wa_word_i-text.
           IF NOT wa_out-ltext IS INITIAL.
             MODIFY it_out FROM wa_out INDEX lv_no TRANSPORTING ltext.
           ENDIF.
           CLEAR: wa_out-ltext, wa_word_i.
         ENDIF.
       ENDLOOP.
     ENDIF.
   ENDLOOP.
ENDFORM.{code}

                   " FETCH_DATA


modify statement fails when sy-tabix is 3, as it_out has only 2 lines,


Any suggestion will be appreciated.

Former Member
Former Member replied

Hi Badu,

lv_lines = lines( it_out ).

IF NOT wa_out-ltext IS INITIAL.

  if lv_lines <= lv_no.

    MODIFY it_out FROM wa_out INDEX lv_no TRANSPORTING ltext. 

  else.

     wa_out-htext = ''.

    APPEND it_out FROM wa_out.

   endif.

ENDIF.


And i think you`d better put 'Item' loop into 'Header' loop.

Regards,

Archer


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question