cancel
Showing results for 
Search instead for 
Did you mean: 

Deep structure into flat structure

V_Vidhya
Explorer
0 Kudos

Hello all,

I have a deep structure that

TYPES : BEGIN OF ty_deep,

lineid TYPE i,
asset LIKE lt_asset, ( internal table with columns lineid , asset_no )
oper_bud LIKE lt_operbud, ( internal table with columns lineid oper_bud_no )
END OF ty_deep

I have data to an internal table DATA : lt_deep TYPE TABLE OF ty_deep (deep structure) below,

lineid asset(internal table) operbud(internal table)

10 [ (row1) 10 Asset000110 ] [ (row2) 10 Operbud000110 ]

[ (row2) 10 Asset000210 ] ___________________________

20 [ (row1) 20 Asset000120 ] [ (row2) 20 Operbud000120 ]

___________________ [ (row2) 20 Operbud000220 ]

And I have a flat structure like

TYPES : BEGIN OF ty_flat,
lineid TYPE i,
asset_no TYPE char20,
oper_bud TYPE char20,
END OF ty_flat.

An internal table DATA : lt_flat TYPE TABLE OF ty_flat.

I want my output to be in format below

Lineid asset_no oper_bud

10 Asset000110 Operbud000110

10 Asset000210 Operbud000210

20 Asset000120 Operbud000120

20 Asset000220 Operbud000220

Kindly help me to solve this.

Thank you,

Vidhya V

Sandra_Rossi
Active Contributor

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Sandra_Rossi
Active Contributor
0 Kudos

I don't understand the difficulty. What exact issue do you have?

Accepted Solutions (1)

Accepted Solutions (1)

FredericGirod
Active Contributor
LOOP AT it_deep
     REFERENCE INTO DATA(o_deep_line).
  DO.
    READ TABLE o_deep_line->asset REFERNCE INTO DATA(o_asset_subline) INDEX sy-index.
    IF o_asset_subline IS BOUND.
      data(lv_asset_subline) = o_asset_subline->....
    ENDIF.
    READ TABLE o_deep_line->oper_bud REFERENCE INTO DATA(o_oper_subline) INDEX sy-index.
    IF o_oper_subline IS BOUND.
      data(lv_oper_bud) = o_oper_subline->....
    ENDIF.
    if o_oper_subline is not bound and o_asset_subline is not bound.
      exit.
    else.
       append value #( lineid = o_deep_line->lineid 
                       asset  = lv_asset_subline
                       operbud = lv_oper_bud       ) to it_flat.
    endif.
  ENDDO.
ENDLOOP.

something like that (not tested, not re-readed)

Answers (0)