Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get data from table reference into ITAB?

martin_lehmann4
Active Participant
0 Likes
3,394

Hello all,

I try to use methods cl_rssh_hierarchy_func=>get and cl_rssh_hierarchy_func=>update - in doing so both methods are working fine, i.e. the first delivers a subtree in parameter E_R_HTAB with Type Ref To DATA and the update method writes a subtree back to the hierarchy with parameter I_T_HTAB and Type TABLE. Unfortunately I have an issue transforming the hierarchy data from Ref To DATA into an ITAB for the TABLE parameter - one of my attempts amongst others was this one:

         

           DATA: lt_htab            TYPE rshi_t_rsnode1,
                    ls_htab            LIKE LINE OF lt_htab,
                    lr_htab            TYPE REF TO data,
                    dref               TYPE REF TO data,
                    lt_htab_dref   LIKE TABLE OF dref.

           FIELD-SYMBOLS: <ls_rsthiernode>  LIKE LINE OF mt_rsthiernode,
                                       <dpak_fields> TYPE any,
                                        <s_hieid>        TYPE rshieid.
          
  

    CREATE DATA lr_htab LIKE LINE OF lt_htab

          

           *

           * getting subtree with cl_rssh_hierarchy_func=>get here
           *


             GET REFERENCE OF lt_htab_dref INTO lr_htab.
             ASSIGN lr_htab->* TO <dpak_itab>.

            LOOP AT lt_htab_dref ASSIGNING <dpak_fields>.
               ASSIGN COMPONENT 'RSHIEID' OF STRUCTURE <dpak_fields> TO <s_hieid>.
               ls_htab-hieid = <s_hieid>.
               APPEND ls_htab TO lt_htab.
            ENDLOOP.

           *

           * writing subtree with cl_rssh_hierarchy_func=>update here
           *

Sadly no data is in structure c_t_srcpak ...

Can you show me an example which solves this task?

Best regards, Martin

Hello all,

I try to use methods cl_rssh_hierarchy_func=>get and cl_rssh_hierarchy_func=>update - in doing so both methods are working fine, i.e. the first delivers a subtree in parameter E_R_HTAB with Type Ref To DATA and the update method writes a subtree back to the hierarchy with parameter I_T_HTAB and Type TABLE. Unfortunately I have an issue transforming the hierarchy data from Ref To DATA into an ITAB for the TABLE parameter - one of my attempts amongst others was this one:

         

           DATA: lt_htab            TYPE rshi_t_rsnode1,
                    ls_htab            LIKE LINE OF lt_htab,
                    lr_htab            TYPE REF TO data,
                    dref               TYPE REF TO data,
                    lt_htab_dref   LIKE TABLE OF dref.

           FIELD-SYMBOLS: <ls_rsthiernode>  LIKE LINE OF mt_rsthiernode,
                                       <dpak_fields> TYPE any,
                                        <s_hieid>        TYPE rshieid.
          
  

    CREATE DATA lr_htab LIKE LINE OF lt_htab

          

           *

           * getting subtree with cl_rssh_hierarchy_func=>get here
           *


             GET REFERENCE OF lt_htab_dref INTO lr_htab.
             ASSIGN lr_htab->* TO <dpak_itab>.

            LOOP AT lt_htab_dref ASSIGNING <dpak_fields>.
               ASSIGN COMPONENT 'RSHIEID' OF STRUCTURE <dpak_fields> TO <s_hieid>.
               ls_htab-hieid = <s_hieid>.
               APPEND ls_htab TO lt_htab.
            ENDLOOP.

           *

           * writing subtree with cl_rssh_hierarchy_func=>update here
           *

Sadly no data is in structure c_t_srcpak ...

Can you show me an example which solves this task?

Best regards, Martin

2 REPLIES 2
Read only

martin_lehmann4
Active Participant
0 Likes
1,788

Hello once more,

the problem is solved, it works like this:

  DATA:     lt_htab            TYPE rshi_t_rsnode1,
                 ls_htab            LIKE LINE OF lt_htab,
                 lr_htab            TYPE REF TO data.
  FIELD-SYMBOLS:

                 <dpak_itab>        TYPE ANY TABLE,
                 <dpak_fields>      TYPE LINE OF rshi_t_rsnode1,
                 <s_hieid>          TYPE rshieid.

  CREATE DATA lr_htab LIKE LINE OF lt_htab.

 

           *

           * getting subtree with cl_rssh_hierarchy_func=>get here
           *

  ASSIGN lr_htab->* TO <dpak_itab>.

  LOOP AT <dpak_itab> ASSIGNING <dpak_fields> CASTING.
    ASSIGN COMPONENT 'HIEID' OF STRUCTURE <dpak_fields> TO <s_hieid>.
    ls_htab-hieid = <s_hieid>.

    "further processing ...
    APPEND ls_htab TO lt_htab.
  ENDLOOP.

Read only

0 Likes
1,788

Hi Martin,

                 Hi Saw your post that with GETREFERENCE  and with out GETREFERENCE and you used CASTING when Looping, can you explain why you kept CASTING in Looping and i also tried but it is giving error and i declared <dpak_fields> type any , So i changed like line of lt_htab and i am not getting error .

So , Please explain the Purpose of CASTING .

Thanks,

Raghunadh.K