12-06-2008 3:46 PM
Hi ,
I would like to append the records from a field symbol of one type to an internal table of another type.
<ASSIGN x_buffer_ref->* TO <fs_buffer_records>.
APPEND <fs_buffer_records> TO i_buffer_records.>
Is this possible?? If Not, please tell me how would i do this??
Thanks,
Shamim
12-06-2008 6:07 PM
Hi
Yes it can, but u make sure the field-symbol for flat workarea (<fs_buffer_records>) has the same structure of field-symbols for internal table <i_buffer_records.>.
So <fs_buffer_records.> and <i_buffer_records.> has to assign to variable having the same structure:
TABLES BKPF.
DATA: ITAB LIKE STANDARD TABLE OF BKPF.
FIELD-SYMBOLS: <I_BUFFER_RECORDS> TYPE TABLE,
<FS_BUFFER_RECORDS> TYPE ANY.
ASSIGN ITAB[] TO <I_BUFFER_RECORDS>.
ASSIGN BKPF TO <FS_BUFFER_RECORDS>.
APPEND <FS_BUFFER_RECORDS> TO <I_BUFFER_RECORDS>.
Max
Edited by: max bianchi on Dec 6, 2008 7:08 PM
12-06-2008 4:33 PM
Hi Shamim
Instead of Append use assign .
Check this link for some info:
Check this piece also:
If it is helpful .
LOOP AT Itab ASSIGNING <wa_itab>.
ASSIGN COMPONENT 1 OF STRUCTURE <wa_itab> TO <wa_itab1>.
ASSIGN COMPONENT 2 OF STRUCTURE <wa_itab> TO <wa_itab2>.
ASSIGN component 3 OF STRUCTURE <wa_itab> TO <wa_itab3>.
WRITE: / <wa_itab1>,<wa_itab2>,<wa_itab3>.
ENDLOOP.
Regards
Neha
Edited by: Neha Shukla on Dec 6, 2008 10:17 PM
12-06-2008 5:42 PM
if the Field symbol structure and the table structure are diff appens is not possible
you can use a move-corresponding from FS to wa_table and append to table.
12-06-2008 6:07 PM
Hi
Yes it can, but u make sure the field-symbol for flat workarea (<fs_buffer_records>) has the same structure of field-symbols for internal table <i_buffer_records.>.
So <fs_buffer_records.> and <i_buffer_records.> has to assign to variable having the same structure:
TABLES BKPF.
DATA: ITAB LIKE STANDARD TABLE OF BKPF.
FIELD-SYMBOLS: <I_BUFFER_RECORDS> TYPE TABLE,
<FS_BUFFER_RECORDS> TYPE ANY.
ASSIGN ITAB[] TO <I_BUFFER_RECORDS>.
ASSIGN BKPF TO <FS_BUFFER_RECORDS>.
APPEND <FS_BUFFER_RECORDS> TO <I_BUFFER_RECORDS>.
Max
Edited by: max bianchi on Dec 6, 2008 7:08 PM
12-07-2008 8:59 AM
Hi All,
I've tried all the above options but could not find the correct way of assigning all the fields of a field symbol to an internal table dynamically.
My requirement:
DATA : i_buffer-rname TYPE arc_buffer,
x_buffer_ref TYPE REF TO data,
x_buffer_records TYPE arc_buffer,
i_buffer_records TYPE TABLE OF arc_buffer.
FIELD-SYMBOLS: <fs_structure_type> TYPE ANY,
<fs_total_table> TYPE ANY.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING
ARCHIVE_HANDLE = v_handle
IMPORTING
RECORD_STRUCTURE = i_buffer-rname
RECORD_REF = x_buffer_ref
The structure i_buffer-rname will be filled up with the table name and x_buffer_ref will have the records.
ASSIGN i_buffer-rname TO <fs_structure_type>.
ASSIGN x_buffer_ref->* TO <fs_total_table>.
MOVE-CORRESPONDING <fs_total_table> TO x_buffer_records.
APPEND x_buffer_records TO i_buffer_records.
If i'm executing the above code, contents of all the fields in the internal i_buffer_records are shown as 000 since the table structures of the internal table and field symbol <fs_total_table> are different.
Please help me in defining an internal table which would create it's physical structure dynamically taking the fields of a field-symbol.
Thanks,
Shamim
12-07-2008 10:01 AM
Hello Shamim ,
Try this....
CONSTANTS : k_vbrk_vbeln(20) TYPE c VALUE '(SAPLV60A)vbrk-vbeln',
k_xvbrp(17) TYPE c VALUE '(SAPLV60A)xvbrp[]'.
* Field symbols
FIELD-SYMBOLS: <l_vbrk_vbeln> TYPE ANY,
<t_xvbrp> TYPE TABLE,
<wa_vbrp> TYPE vbrp.
* Variable holding the zero quantity
DATA : l_vbrp_fkimg TYPE vbrp-fkimg.
* Assign zero
CLEAR : l_vbrp_fkimg,
l_zero_qty.
* Retrieve the values of invoice and check for the quantity
ASSIGN (k_vbrk_vbeln) TO <l_vbrk_vbeln>.
IF sy-subrc = 0.
ASSIGN (k_xvbrp) TO <t_xvbrp>.
IF sy-subrc = 0.
* Check if any one item has quantity not equal to zero.
LOOP AT <t_xvbrp> ASSIGNING <wa_vbrp>.
* Check for the invoice number
IF <wa_vbrp>-vbeln = <l_vbrk_vbeln>.
* Check if the invoice quanitity is zero.
IF <wa_vbrp>-fkimg NE l_vbrp_fkimg.
l_zero_qty = 'X'.
CLEAR <wa_vbrp>.
EXIT.
ENDIF.
ELSE.
CLEAR <wa_vbrp>.
EXIT.
ENDIF.
ENDLOOP.
* Check if the invoice quanitity is zero.
IF l_zero_qty IS INITIAL.
* Stop the idoc creation
sy-subrc = 4.
ENDIF.
ENDIF.
ENDIF.
Thanks,
Rahul
12-07-2008 1:19 PM
Hello Shamim,
You can get the structure of the internal table using the following code :
type-pools : abap.
field-symbols: <dyn_table> type table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( tab ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Thanks,
Rahul
12-13-2008 1:15 PM
Hi Rahul,
I got the records from table into field symbol but not able to display the same.
Could you help me out with this??
Thanks,
Shamim
12-13-2008 1:27 PM
Hi Shamim,
First pass the records from field symbol into dynamic internal table you had created in the list display function module and dont forget to pass the name of dynamic structure in the same FM.
This will display the records into a new layout as the output.
Thanks,
Rahul.
12-13-2008 1:30 PM
I got all the records from dynamic internal table in the output when i passed it in the FM REUSE_ALV_LIST_DISPLAY.
Thanks,
Shamim
12-13-2008 1:33 PM
But I need all the records from dynamic internal table into the table which was passed in the TABLES parameter of the function module since I've created a function module in which i m writing all these logics.
Thanks,
Sam.
02-04-2010 2:22 PM