‎2010 Nov 26 5:07 AM
Hi Experts,
I have some queries.
Letz say there exists 3 internal tables which were created dynamically using cl_alv_table_create=>create_dynamic_table All corresponds to HR infotype tables PA0001,PA0002....etc.
<fs_0001>
<fs_0002>
<fs_0003>
During data fetch , based on some condition how to choose a particular internal table to store the data among these.
i.e IF wa_data-infty = 0001.
store the data into the <fs_0001>.
elseif wa_data-infty = 0002.
store the data into the <fs_0002>.
elseif wa_data-infty = 0003.
store the data into the <fs_0003>.
endif.
Also , How to create the Field symbols dynamically ???
Pls.help.
Thanks,
‎2010 Nov 26 5:16 AM
hi expert.
this is the sample code using this code we can solve ur problem.
Below code intenal will create dynamcally u can pass the infor type no to wa-infty then automatically internal table created
related infortype table like (PA0001)
DATA: pannnn_ref TYPE REF TO data,
pnnnn_str TYPE REF TO cl_abap_structdescr,
pannnn_wa_ref TYPE REF TO data.
FIELD-SYMBOLS :<psnnnn> TYPE STANDARD TABLE,
<pannnn_wa> TYPE ANY,
<pacccc_wa> TYPE c,
<value> TYPE ANY.
IF wa_data-infty = 0001.
CONCATENATE 'PA' wA_data-infty INTO dbtab.
CREATE DATA pannnn_ref TYPE STANDARD TABLE OF (dbtab).
ASSIGN pannnn_ref->* TO <psnnnn>.
CREATE DATA pannnn_wa_ref TYPE (dbtab).
ASSIGN pannnn_wa_ref->* TO <pannnn_wa>.
ASSIGN <pannnn_wa> TO <pacccc_wa> CASTING.
SELECT * FROM (dbtab) INTO TABLE <psnnnn>.
elseif wa_data-infty = 0002.
clear:dbtab.
refresh:<psnnnn>.
CONCATENATE 'PA' wA_data-infty INTO dbtab.
CREATE DATA pannnn_ref TYPE STANDARD TABLE OF (dbtab).
ASSIGN pannnn_ref->* TO <psnnnn>.
CREATE DATA pannnn_wa_ref TYPE (dbtab).
ASSIGN pannnn_wa_ref->* TO <pannnn_wa>.
ASSIGN <pannnn_wa> TO <pacccc_wa> CASTING.
SELECT * FROM (dbtab) INTO TABLE <psnnnn>.
endif.
Thanks&Regards,
Muralii.
Edited by: Muralii on Nov 26, 2010 6:17 AM
‎2010 Nov 26 5:23 AM
Thanks for your reply..
Let me check this one and assign pts..
‎2010 Nov 26 6:21 AM
Hi Murali,
CONCATENATE 'PA' wA_data-infty INTO dbtab.
CREATE DATA pannnn_ref TYPE STANDARD TABLE OF (dbtab).
ASSIGN pannnn_ref->* TO <psnnnn>.
CREATE DATA pannnn_wa_ref TYPE (dbtab).
ASSIGN pannnn_wa_ref->* TO <pannnn_wa>.
ASSIGN <pannnn_wa> TO <pacccc_wa> CASTING.
SELECT * FROM (dbtab) INTO TABLE <psnnnn>.
Instead of refering database tables via dbtab , is it possible to refer the already created <dynamic internal table here>??
Thanks,
‎2010 Nov 26 6:36 AM
Hi Lakshmiraj,
Yes it is possible we can declare the internal table with your fields like.
TYPES:BEGIN OF TY_DATA,
PERNR TYPE PERSNO,
PLANS TYPE PLANS,
END OF TY_DATA.
DATA:WA TYPE TY_DATA.
CREATE DATA pannnn_ref TYPE STANDARD TABLE OF (WA).
ASSIGN pannnn_ref->* TO <psnnnn>.
CREATE DATA pannnn_wa_ref TYPE (dbtab).
ASSIGN pannnn_wa_ref->* TO <pannnn_wa>.
ASSIGN <pannnn_wa> TO <pacccc_wa> CASTING.
Now internal table will created with two fields like we can create if it is not possible tell the
exact requirement is given to u
thanks
muralii.
‎2010 Nov 26 5:23 AM
create a work area like
field-symbols : <wa_infotype > type any .
then
read table <fs_0001> assigning <wa_infotype> index one .
or
loop at <fs_0001> assigning <wa_infotype> .
whatever suits you the best
after that you can compare <wa_infotype>-infotype
and store the data in corresponding workareas as required .