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

Passing internal table data to a variable

Former Member
0 Likes
2,101

Dear experts,

i am having below code

ASSIGN (w_dyn_tbl_fld) TO <fs_dyn_fld_data>.

IF sy-subrc <> 0.

CLEAR <fs_dyn_fld_data>.

ENDIF.

and this is in loop of an internal table having 30 records at 28 record im having value REGUH-VBLNR in (w_dyn_tbl_fld) and

<fs_dyn_fld_data> is having the value as 2000022827 and here in assigning is getting failed

and hence it is clearing <fs_dyn_fld_data> data.

which should nt happen

dont know why it is happening.

i have internal table it_reguh which is having value as it_reguh-vblnr.

i need to declare one work area and than from this internal table i have to pass this value to an work area.

kindly suggest how to proceed

thank u

regards

ravikumar

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,219

Hi Ravi,

your question is not clear. be more precise.

Read only

0 Likes
1,219

dear keshav,,

see the below code

LOOP AT it_flds_maps_tbl INTO wa_flds_maps_tbl

WHERE ( recty = 'I' ). "I STRUC TABLES

  • POPULATE A VARIABLE WITH TABLENAME-FIELDNAME. >>>

CONCATENATE wa_flds_maps_tbl-tabname

wa_flds_maps_tbl-fieldname

INTO w_dyn_tbl_fld

SEPARATED BY w_seperator.

  • USE THE VARIABLE TO ASSIGN A REFRENCE TO THE ACTUAL TABLE-FIELD

  • FOR RETRIEVEING THE DATA USING A FILED SYMBOL. >>>

ASSIGN (w_dyn_tbl_fld) TO <fs_dyn_fld_data>.

IF sy-subrc <> 0. "BS1+

CLEAR <fs_dyn_fld_data>. "BS1+

ENDIF. "BS1+

CLEAR w_clspace.

  • QUERY THE TYPE OF FIELD

CLEAR w_type.

DESCRIBE FIELD <fs_dyn_fld_data> TYPE w_type.

CASE w_type.

  • ABSOLUTE VALUE AND THOUSAND SEPARATORS SUPRESSED

WHEN 'P' OR 'I' OR 'F'.

WRITE <fs_dyn_fld_data> TO w_clspace

NO-SIGN NO-GROUPING LEFT-JUSTIFIED.

IF <fs_dyn_fld_data> < 0.

CONCATENATE '-' w_clspace INTO w_clspace.

ENDIF.

  • INTERNAL REPESENTATION IS PASSED

WHEN 'D'.

MOVE <fs_dyn_fld_data> TO w_clspace .

WHEN OTHERS.

*IF CONVERSION ENTRIES ARE MAINTAINED THEN CONSIDER THESE

IF wa_flds_maps_tbl-conv_exists = 'X'.

READ TABLE it_flds_conv_tbl INTO wa_flds_conv_tbl

WITH KEY tabname = wa_flds_maps_tbl-tabname

fieldname = wa_flds_maps_tbl-fieldname

oldvalue = <fs_dyn_fld_data>.

IF sy-subrc EQ 0.

WRITE wa_flds_conv_tbl-newvalue TO w_clspace.

ENDIF.

ELSE.

WRITE <fs_dyn_fld_data> TO w_clspace.

ENDIF.

ENDCASE.

  • INCLUDE PREFIX AND SUFFIX

IF NOT w_clspace IS INITIAL.

CONCATENATE wa_flds_maps_tbm-prefix w_clspace

wa_flds_maps_tbm-suffix INTO w_clspace SEPARATED BY space.

ENDIF.

*REMOVE # FROM RECORD

REPLACE '#' INTO w_clspace WITH ''.

SHIFT w_clspace LEFT DELETING LEADING space.

  • CONSTRUCT A STRING WHICH WOULD CONTAIN THE DATA EXTRACTED BY THE

  • FIELD SYMBOL AND DELIMIT EACH DATA EXTRACT BY A DELIMITER. >>>

w_offset = STRLEN( w_i_record ).

w_len = STRLEN( w_clspace ).

WRITE w_clspace TO w_i_record+w_offset(w_len).

  • IF DELIMITER IS REQUIRED AFTER THE FIELD

IF wa_flds_maps_tbl-delrq EQ 'X'.

CONCATENATE w_i_record c_delimiter INTO w_i_record.

ELSE.

CONCATENATE w_i_record '^' INTO w_i_record.

ENDIF.

*... GET RID OF THE SOFT SPACE FOR EMPTY FIELD

REPLACE '^' INTO w_i_record WITH ''.

REPLACE '|^' INTO w_i_record WITH '|' .

REPLACE '^|' INTO w_i_record WITH '|'.

REPLACE ' |' INTO w_i_record WITH '|'. "MAY NOT BE REQD???

ENDLOOP. " ENDLOOP FOR I STRUC CONSTRUCTION.

in assining w_dyn_tbl_fld to fs_dyn_fld_data

it is getting failed due to miss assigning

so i just want to know whether i can create a variable of type any

and i pass this fs_dyn_fld_data to that variablke or not

and whether this variable value can be used in where condition(vblnr = reguh-vblnr) or not in loop of the below code

LOOP AT it_regup INTO regup

WHERE ( laufd = reguh-laufd )

AND ( laufi = reguh-laufi )

AND ( xvorl = reguh-xvorl )

AND ( zbukr = reguh-zbukr )

AND ( lifnr = reguh-lifnr )

AND ( kunnr = reguh-kunnr )

AND ( empfg = l_w_empfg ) " BY RMK

AND ( vblnr = reguh-vblnr ).

Read only

0 Likes
1,219

Hi,

The reason is data type conflict.

check <FS> type and Varible type both are compareble or not.

Read only

0 Likes
1,219

self solved

Read only

Former Member
0 Likes
1,219

Hello,

Check field symbol <fs_dyn_fld_data> type.

Try declaring this way.

field-symbol: <fs_dyn_fld_data> type any.

ASSIGN (w_dyn_tbl_fld) TO <fs_dyn_fld_data>.

IF sy-subrc ne 0.

UNASSIGN <fs_dyn_fld_data>.

ENDIF.

Also can you share if you still get dump.. post your dump declaration.

Regards,

Sameer