Skip to Content
avatar image
Former Member

logic to get same text for 2 line items

hi all,

i have an issue in my report,

i have a final internal table. fileds in the table are

bukrs belnr gjahr buzei sgtxt

0010 12345 2008 01 text

0010 12345 2008 02 -


now the problem is if the belnr is same thn in the final internal table the above sgtxt shoud come for second line item if the second line item is initial ,i shoud get the output as

bukrs belnr gjahr buzei sgtxt

0010 12345 2008 01 text

0010 12345 2008 02 text

please help me how to write code for this

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 20, 2008 at 11:55 AM

    Hi,

    Use this :

    Loop at itab.

    if itab-sgtext is initial .

    read table itab into wa with key bukrs = itab-bukrs

    belnr = itab-bukrs

    gjahr = itab-bukrs

    buzei = itab-bukrs

    sgtext <> space.

    if sy-subrc eq 0.

    itab-sgtext = wa-sgtext.

    modify itab transporting sgtext.

    endif.

    endif.

    endloop.

    Hope this helps.

    Rgds,

    Sandeep

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 20, 2008 at 11:58 AM

    Hi,

    u can do as follows...

    DATA: ITAB_T LIKE LINE OF <ITAB>,
              SGTXT_T TYPE <ITAB>-SGTXT.
    
    SORT <ITAB> BY BELNR SGTXT
    
    LOOP AT <ITAB>.
       ITAB_T = <ITAB>.
       AT NEW BELNR.
          T_BELNR = <ITAB_T-SGTXT.
       ENDAT.
       IF <ITAB>-SGTXTR IS INITIAL.
          ITAB_T-SGTXT = SGTXT_T.
       ENDIF.
       APPEND ITAB_T INTO <ITAB_FINAL>.
       CLEAR: ITAB_T,
                   SGTXT_T.
    ENDLOOP.
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 20, 2008 at 12:05 PM

    Hi,

    Move this values to one more internal table.

    Loop at 1 internal table.

    read second internal table with belnr.

    If check that text is initial.

    second internal text = first internal table text.

    endif.

    Modify second internal table with text.

    endloop..

    Now 2 internal table will have all the rows with text

    Add comment
    10|10000 characters needed characters exceeded