2008 Sep 22 9:54 PM
Hi,
I need help on defining a work area with referencing to a dynamic structure name. Could you please help?
Thanks,
Chuong
2008 Sep 22 10:55 PM
simplest way to create a work area for your dynamic table
data: l_wa_ref type ref to data.
"Create a data
create data l_wa_ref like line of <f_data>.
2008 Sep 22 10:24 PM
You need to use the field-symbols to get an access of the dynamica structure. Insdie the loop, you need to access each field individually using the Field symbols.
Like:
FIELD-SYMBOLS: <LT_TEXT> TYPE ANY TABLE,
<LA_TAB> TYPE ANY,
<LF_ITEXT> TYPE ANY.
LOOP AT <LT_TEXT> ASSIGNING <LA_TAB>.
ASSIGN COMPONENT: 'FIELD1' OF STRUCTURE <LA_TAB> TO <LF_ITEXT>.
ENDLOOP.
Regards,
Naimesh Patel
2008 Sep 22 10:25 PM
This is how you can do this.
<line> will be your work area.
DATA: l_struct TYPE REF TO data.
FIELD-SYMBOLS: <table> TYPE STANDARD TABLE, " Dynamic Table
<line> TYPE ANY.
CREATE DATA l_struct LIKE LINE OF <table>.
ASSIGN l_struct->* TO <line>.A
2008 Sep 22 10:25 PM
One simple approach can be using class cl_alv_table_create.
data: i_table type ref to data.
field-symbols : <list> type table .
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = lt_alv_cat
importing
ep_table = i_table .
assign i_table->* to <list> .
Enjoy SAP.
Pankaj Singh
2008 Sep 22 10:55 PM
simplest way to create a work area for your dynamic table
data: l_wa_ref type ref to data.
"Create a data
create data l_wa_ref like line of <f_data>.
2008 Sep 23 7:40 PM
I have a string of 2000 chars that will be populated with different formats and I need to dynamicly define a work area (wa) so I can map the data from the string to my work area. I am having a difficulty in defining such work area.
For example,
String can have data of VBAK or VBAP and I need a work area defined accordingly for my mapping like
wa = string.
Please help,
Thanks!
2008 Sep 23 10:20 PM
Check this coding:
PARAMETERS:
p_type TYPE typename OBLIGATORY DEFAULT 'VBAK'.
DATA:
gr_dataref TYPE REF TO data.
FIELD-SYMBOLS:
<gfs> TYPE ANY.
CREATE DATA gr_dataref TYPE (p_type).
ASSIGN gr_dataref->* TO <gfs>.
<gfs> will take the structure from the name parameter, in this case table VBAK by default.
So if you have VBAK data in your string, doing the assignment <gfs> = string would split the data over the different fields.
What this code is lacking is exception handling, which depends on the SAP version you're at.
If your WAS is >= 6.20, you can use exception classes, so you should catch exception CX_SY_CREATE_DATA_ERROR:
TRY.
CREATE DATA gr_dataref TYPE (p_type).
CATCH CX_SY_CREATE_DATA_ERROR.
" Exception handling in here
ENDTRY.
On older releases you should use CATCH SYSTEM-EXCEPTIONS ... ENDCATCH instead.
Regards
Edited by: Alejandro Bindi on Sep 23, 2008 6:23 PM
2008 Sep 24 7:28 PM
Hi Alejandro Bindi,
My problem was resolved. Thank you for helping me!
Chuong
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |