Tree ALV


 type-pools : slis.

types : begin of ty_scarr,

          carrid type scarr-carrid,

        end of ty_scarr.

types : begin of ty_spfli,

        carrid type spfli-carrid,

        connid type spfli-connid,

       end of ty_spfli.

 

types : begin of ty_sflight,

        carrid type sflight-carrid,

        connid type sflight-connid,

        fldate type sflight-fldate,

       end of ty_sflight.

 

data : it_scarr type table of ty_scarr ,

       wa_scarr type ty_scarr,

       it_spfli type table of ty_spfli,

        wa_spfli type ty_spfli,

        it_sflight type table of ty_sflight ,

         wa_sflight type ty_sflight,

         it_node type table of snodetext,

          wa_node type snodetext .

 

start-of-selection.

  perform data-fetch.

  perform build_tree.

  perform display_tree.

*-------------------------------------------------------------*

form data-fetch .

  select carrid from scarr into table it_scarr.

 

  if it_scarr is not initial.

    select carrid connid from spfli into table it_spfli for all entries in it_scarr where carrid  = it_scarr-carrid.

    if it_spfli is not initial.

      select carrid

             connid

             fldate from sflight into table it_sflight for all entries in it_spfli where carrid = it_spfli-carrid and connid = it_spfli-connid.

    endif.

  endif.

  sort : it_scarr by carrid,

          it_spfli by carrid connid,

          it_sflight by carrid connid fldate.

endform.                    ” DATA-FETCH


 *-------------------------------------------------------------*

form build_tree .

  clear : wa_node, it_node.

 

  wa_node-type = ‘T’.

  wa_node-name = ‘Airline’.

  wa_node-tlevel = ’01’.

  wa_node-nlength = ’08’.

  wa_node-color = ’05’.

  wa_node-text = ‘CODE’.

  wa_node-tlength = ’04’.

  wa_node-tcolor = ’05’.

  append wa_node to it_node.

  clear wa_node.

 

  loop at it_scarr into wa_scarr.

    wa_node-type = ‘P’.

    wa_node-name = ‘CARRID’.

    wa_node-tlevel = ’02’.

    wa_node-nlength = ’08’.

    wa_node-color = ’06’.

    wa_node-text = wa_scarr-carrid.

    wa_node-tlength = ’04’.

    wa_node-tcolor = ’06’.

    append wa_node to it_node.

    clear wa_node.

 

    loop at it_spfli into wa_spfli.

      wa_node-type = ‘P’.

      wa_node-name = ‘CONNID’.

      wa_node-tlevel = ’03’.

      wa_node-nlength = ’08’.

      wa_node-color = ’04’.

      wa_node-text = wa_spfli-connid.

      wa_node-tlength = ’04’.

      wa_node-tcolor = ’04’.

      append wa_node to it_node.

      clear wa_node.

 

      LOOP AT IT_SFLIGHT INTO WA_SFLIGHT.

      wa_node-type = ‘P’.

      wa_node-name = ‘fldate’.

      wa_node-tlevel = ’04’.

      wa_node-nlength = ’06’.

      wa_node-color = ’04’.

      wa_node-text = wa_sflight-fldate.

      wa_node-tlength = ’10’.

      wa_node-tcolor = ’04’.

      append wa_node to it_node.

      clear wa_node.

 

        ENDLOOP.

    endloop.

  endloop.

endform.                    ” BUILD_TREE

*-------------------------------------------------------------*

form display_tree .

  call function ‘RS_TREE_CONSTRUCT’

* EXPORTING

*   INSERT_ID                = ‘000000’

*   RELATIONSHIP             = ‘ ‘

*   LOG                      =

    tables

      nodetab                  = it_node.

 

  call function ‘RS_TREE_LIST_DISPLAY’

   exporting

     callback_program          = sy-cprog.

            

endform.                    " DISPLAY_TREE

Output-


 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s