Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8644

Dynamic Field Symbols with Structures

$
0
0

Hello,

 

I am stuck on a piece of code and looking for some help.  I am trying to figure out how to assign values in a structure of a dynamically defined field symbol to the structure inside another dynamically defined field symbol.  Here is my code and some comments.  Basically I am uploading data via a flatfile and placing it into a dynamically defined field symbol.

 

 

DATA:   

lr_area     TYPE REF TO cl_sem_planarea_attributes, 

lr_t_data   TYPE REF TO data, 

lr_s_data   TYPE REF TO data, 

lr_s_chas   TYPE REF TO data, 

lr_s_kyfs   TYPE REF TO data.

 

FIELD-SYMBOLS:      

<lt_data> TYPE STANDARD TABLE,    

<ls_data> TYPE ANY,    

<ls_chas> TYPE ANY,    

<ls_kyfs> TYPE ANY.

 

DATA: ls_chasel TYPE upc_ys_chasel,     

ls_charng TYPE upc_ys_charng.

 

FIELD-SYMBOLS:

<f> TYPE ANY,              

<chas> TYPE TABLE,              

<kyfs> TYPE ANY. 

 

CALL METHOD cl_sem_planarea_attributes=>get_instance   

EXPORTING       i_area      = i_area   

RECEIVING       er_instance = lr_area. 

 

CHECK sy-subrc = 0. 

CREATE DATA lr_s_data TYPE (lr_area->typename_s_data). 

ASSIGN lr_s_data->*   TO <ls_data>. 

 

CREATE DATA lr_t_data TYPE (lr_area->typename_t_data). 

ASSIGN lr_t_data->*   TO <lt_data>. 

 

CREATE DATA lr_s_chas TYPE (lr_area->typename_s_chas). 

ASSIGN lr_s_chas->*   TO <ls_chas>. 

 

CREATE DATA lr_s_kyfs TYPE (lr_area->typename_s_kyfs). 

ASSIGN lr_s_kyfs->*   TO <ls_kyfs>. 

 

LOOP AT gt_file INTO ls_file.   

CLEAR <ls_data>.   

MOVE-CORRESPONDING ls_file TO <ls_kyfs>. " Map key figures   

MOVE-CORRESPONDING ls_file TO <ls_chas>. " Map chars

*    MOVE-CORRESPONDING ls_file TO <ls_data>. " Map data

*        ASSIGN COMPONENT 'ls_chas' OF STRUCTURE <ls_Data> TO <chas> .

*        IF sy-subrc = 0.

**          <chas> = <ls_chas>.

*MOVE-CORRESPONDING <ls_chas> to <chas>.

*        ENDIF.     

<chas> = <ls_chas>.     

LOOP AT <chas> INTO ls_chasel.     

READ TABLE ls_chasel-t_charng INTO ls_charng INDEX 1.     

IF sy-subrc = 0 AND ls_charng-option = 'EQ'.       

ASSIGN COMPONENT ls_chasel-chanm OF STRUCTURE <ls_chas> TO <ls_data>.       

 

IF sy-subrc = 0.         

<ls_data> = ls_charng-low.       

ENDIF.     

ENDIF.   

ENDLOOP.   

 

COLLECT <ls_data> INTO <lt_data>. 

ENDLOOP.

 

Ls_chasel has 2 components:

Chanm (a char 30 which contains the component’s name)

T_CHARNG (a table with values for chanm)

 

Ls_data has 2 components:

S_chas (a structure with a list of components and values – same list as would have)

S_kyfs (a structure with a list of components and values – same list as would have)

 

Lt_data is a table of ls_data

 

I need to get the data in ls_chas into the ls_chas structure of ls_data and the ls_kyfs data into the ls_kyfs structure of ls_chas and append ls_chas to lt_data.  Anything that is commented out is something I tried that didn't work.  RIght now I get a dump at the 'loop at <chas> into ls_chasel' that the field symbol is not assigned.

 

Thanks for your help!


Viewing all articles
Browse latest Browse all 8644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>