Moving field-symbol data to an internal table
Hi
I have defined a field-symbol
field-symbols: <fs_table> type standard table.
Dynamically, I have populated some records in this <fs_table> & now I would like to copy this data into another internal table. I would like to know the best method to declare/create this internal table & to copy the records from <fs_table> to this internal table.
Thanks,
Sanjay
if you know the structure of the reuslt in the first place, instead of dynamic itab you would have created a normal itab.
do you want the new itab to be same as <l_table> ?
then that also needs to be dynamically created.
the best thing possible in you case is.
field-symbols: <newtab> type any table.
if <l_table> is assinged.
assign <l_table> to <newtab>.
endif .
if you tell us why you want to move the <l_table> records to another similar itab, may be could come up with suggestion which dosesnt require you to move the data at all
Raja
Similar Messages
-
Problem in assigning field symbol to a nested internal table
Hi All,
I have searched the forum but could not find a solution to this problem. I have a requirement where I need to define an internal table within an internal table, so I have used pointer within the outer internal table(itab2) which point to the inner table. However, I am facing problem while assigning the pointer.
data: begin of struct1 occurs 0,
fld3(10) type C,
end of struct1.
data: begin of itab2 occurs 0,
fld1(10) type C,
fld2(10) type C,
p_inner like ref to struct1,
end of itab2.
field-symbols <inner_table> type any.
I want to assign "itab2->p_inner->* " to "<inner_table>".
However, the following statement is Not working:
assign itab2->p_inner->* to <inner_table>.
I want to fill the values within fields fld1, fld2 and fld3 and append it in itab2.
The final table should be like:
ITAB2:
fld1 fld2 fld3
aa bb cc
dd
ee
11 22 33
44
55
I have tried many other ways too but could not suceed, please help.
Thanks,
Vishal.Thanks Matt,
But how do I append the values within this internal table ??
When I am using the following code:
ls_wa-fld3 = 'A'.
ls_wa-t_in-fld1 = 'B'.
ls_wa-t_in-fld2 = 'C'.
ls_wa-t_in-fld1 = 'D'.
ls_wa-t_in-fld2 = 'E'.
append ls_wa to lt_tab.
Its giving an error that:
The data object "LS_WA" does not have a component called "T_IN-FLD1".
I wanted the values to be appended in the following way in lt_tab:
fld3 fld1 fld2
A B C
D E
Please help. -
Move Field symbol data to Internal table
Dear All,
Please suggest how to move field symbol data to internal table. The requirement is I have dynamic data in Field symbol which to move to table parameter of a function module.
Thanks in Advance
Rams.Dear All,
In need to pass tabular data i.e. multiple entries from field symbol to the table parameter of the custom function module.
Field symbol is declared as below:
FIELD-SYMBOLS: <FS_EXCEL_TAB> TYPE STANDARD TABLE,
<FS_TABLE_HEADER> .
DATA WA_PD LIKE PRICE_DOWNLOAD.
APPEND <FS_TABLE_HEADER> TO <FS_EXCEL_TAB>.
CLEAR <FS_TABLE_HEADER>.
WA_PD-VKORG = <FS_EXCEL_TAB>-VKORG.u201D Problem while using this statement
APPEND WA_PD TO PRICE_DOWNLOAD.
CLEAR WA_PD.
Field symbol <FS_EXCEL_TAB> is populated like this.
VKORG | KUNNR_SH | KUNNR_SP |
0015 | 102105 | 102105 |
Now I need to move this data to table in tables parameter of custom fucntion module.
Thanks in advance,
Rams -
Moving the data from multiple internal tables into a single one
Hello everyone,
I am creating a classical report which uses the following tables.
tables : ekko, ekpo, mara, makt,lfa1.
my input parameter is
Select-options Purchase Order number
Following fields are getting used.
Doc no EKKO-EBELN
Material EKPO-MATNR
Item number EKPO-EBELP
Quantity EKPO-MENGE
Material Group MARA-MATKL
Vendor EKKO-LIFNR
Old Material code MARA-BISMT
Material Desc. MAKT-MAKTX
Vendor name LFA1-NAME1
Now i need to do the following task.
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
3 Find out Old Material code of each and every material from Material master.
4 Find out Material description for each and every material from MAKT.
5 Sort record on Vendor, Purchase Order number and Material.
I have defined seperate internal tables for these operation.
Once i have fetched records into these individual internal tables from the corresponding DB tables i need to move these values into a new internal tables which has all the above fields mentioned
I need to move these values into a new internal table because to display the values on the report.
Any idea for the above ? Plz help with a sample example or some relevant.
Regards,
Ranjith NambiarHi
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
Use inner join and retrive data into one internal table.for Ex ITAB1
3 Find out Old Material code of each and every material from Material master.
Use ITAB1 with for allentries in MARA table to get the onl materil number populate in to one table.
4 Find out Material description for each and every material from MAKT.
Get the Material desc with the same manner as above,
5 Sort record on Vendor, Purchase Order number and Material.
now sort the ITAB1 as you req.
now Loop on the ITAB1.
and read above 2 tables for old matnr and matner deac and append into another table as you want.
Hope this will help.
Regards,
Hiren Patel -
Moving the data of five internal tables to one internal tables.
iam having the five internal table. like below
g_t_vbfa
g_t_vbrk
g_t_vbpa
g_t_kna1
g_t_vbak
this are the five internal tables. each tables having the datas . but each table having the number of records is different. one table having 100 records means another table having 50 records.
previously i used index sys-tabix concept it was not working properly...
my output table is g_t_output_header_data ..
i want to move that output table....
please coding wise give some solution...
thanks
santhoshhi,
chk a sample.
data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1.
data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2.
data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final.
put the date final(merged) internal table
1. loop at itab1.
read table itab2 with key keyfield2 = itab1-keyfield1.
if sy-surc = 0.
itab_final-key_field1 = itab1-keyfield1
itab_final-field1 = itab1-field1.
itab_final-field2 = itab1-keyfield2.
itab_final-field3 = itab2-field2.
itab_final-field4 = itab2-keyfield2.
append itab_final.
clear itab_final.
endif.
endloop.
or
LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop
rgds
Anver -
Filling dynamic internal table with data from other internal table
Hi Friends,
My problem is that i have already built a dynamic internal table
(class int_table->create) but now i want to fill it with data from other internal table.
The dynamic table column name and the field value of the data filled internal table are same, but how to access that column name, since i cant hard code it anyway.
Like if my werks field value is '8001'. I want to place it under the column 8001 of dynamic table, Can anybody help me in this regard?
Awarding points is not a problem for even giving a slight hint.
Best RegardsHi
See this
Dynamic internal table is internal table that we create on the fly with flexible column numbers.
For sample code, please look at this code tutorial. Hopefully it can help you
Check this link:
http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
Sample code:
DATA: l_cnt(2) TYPE n,
l_cnt1(3) TYPE n,
l_nam(12),
l_con(18) TYPE c,
l_con1(18) TYPE c,
lf_mat TYPE matnr.
SORT it_bom_expl BY bom_comp bom_mat level.
CLEAR: l_cnt1, <fs_dyn_wa>.
Looping the component internal table
LOOP AT it_bom_expl INTO gf_it_bom_expl.
CLEAR: l_cnt1.
AT NEW bom_comp.
CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
For every new bom component the material data is moved to
temp material table which will be used for assigning the levels
checking the count
it_mat_temp[] = it_mat[].
Component data is been assigned to the field symbol which is checked
against the field of dynamic internal table and the value of the
component number is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
<fs_check>.
<fs_check> = gf_it_bom_expl-bom_comp.
ENDAT.
AT NEW bom_mat.
CLEAR l_con.
ENDAT.
lf_mat = gf_it_bom_expl-bom_mat.
Looping the temp internal table and looping the dynamic internal table
*by reading line by line into workarea, the materialxxn is been assigned
to field symbol which will be checked and used.
LOOP AT it_mat_temp.
l_nam = c_mat.
l_cnt1 = l_cnt1 + 1.
CONCATENATE l_nam l_cnt1 INTO l_nam.
LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
ENDLOOP.
IF <fs_xy> = lf_mat.
CLEAR lf_mat.
l_con1 = l_con.
ENDIF.
Checking whether the material exists for a component and if so it is
been assigned to the field symbol which is checked against the field
of dynamic internal table and the level of the component number
against material is been passed to the dynamic internal table field
value.
IF <fs_xy> = gf_it_bom_expl-bom_mat.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
CLEAR l_con.
MOVE gf_it_bom_expl-level TO l_con.
CONCATENATE c_val_l l_con INTO l_con.
CONDENSE l_con NO-GAPS.
IF l_con1 NE space.
CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
CLEAR l_con1.
l_cnt = l_cnt - 1.
ENDIF.
<fs_check> = l_con.
l_cnt = l_cnt + 1.
ENDIF.
ENDLOOP.
AT END OF bom_comp.
At end of every new bom component the count is moved to the field
symbol which is checked against the field of dynamic internal table
and the count is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
<fs_check> = l_cnt.
INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
ENDAT.
ENDLOOP.
Reward if useful
Anji -
How to delete data from dynamic internal table
Hi,
I have dynamic internal table and I have some slection screen fields , using these selection screen fields
(select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
and also delete will not work for dynamic table..
as we cannot use assigning with delete..
So how to do this?
and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
so now after selection of data, I need to filter the data from dynamic table.
Is there any way to do this?
Regards,
MrunalHi matt,
I tried with below code as you said. But I am getting dump. can you help?
here is my piece of code.
FIELD-SYMBOLS: <LS_DATA> type any,
<LT_DATA> TYPE table,
<L_FIELD> type any.
ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
IF <L_FIELD> NOT IN SO_BUKRS.
DELETE <LT_DATA>.
ENDIF.
UNASSIGN <L_FIELD>.
ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
IF <L_FIELD> NOT IN SO_BELNR.
DELETE <LT_DATA>.
ENDIF.
UNASSIGN <L_FIELD>.
ENDLOOP.
and here is the description of my dump:->>>
You attempted to access an unassigned field symbol
(data segment 32772).
This error may occur for any of the following reasons:
- You address a typed field symbol before it is set using ASSIGN
- You address a field symbol that points to a line in an internal table
that has been deleted
- You address a field symbol that had previously been reset using
UNASSIGN, or that pointed to a local field that no longer exists
- You address a global function interface parameter, even
though the relevant function module is not active,
that is it is not in the list of active calls. You can get the list
of active calls from the this short dump. -
How to populate field catalogue fields in ALV using dynamic internal table
Hi All,
Please let me know how to populate field catalogue fields in ALV using dynamic internal table.
I have created <dyn_table> using code below.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = g_t_ifc
it_fieldcatalog = g_t_fieldcat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
Now this <dyn_table> has fields like idoc no.,creation date ,
segment field 1, segment field 2 etc..Now idoc no.,creation date are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
In my ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
I tried this way but its not working.
SORT g_t_edid4 BY docnum.
LOOP AT g_t_edidc INTO g_r_edidc.
READ TABLE g_t_edid4 into g_r_edid4
WITH KEY docnum = g_r_edidc-docnum
BINARY SEARCH.
IF sy-subrc = 0.
<dyn_wa> = g_r_edid4-sdata.
MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
CLEAR g_r_edid4.
ENDIF.
MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
LOOP AT g_t_edidc INTO g_r_edidc.
READ TABLE g_t_edid4 into g_r_edid4
WITH KEY docnum = g_r_edidc-docnum
BINARY SEARCH.
IF sy-subrc = 0.
ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
<DYN_FLD> = g_r_edid4-sdata.
" <dyn_wa> = g_r_edid4-sdata.
" Assign each fields like this.
" MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
CLEAR g_r_edid4.
ENDIF.
" MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.
Regards,
Naimesh Patel -
How to populate data into Dynamic Internal Table.
Hi Experts,
I had created one Dynamic Internal table and one static internal table.I want to move data from Static Internal table to Dynamic interal table.And aslo the number of coloum of these two tables are not same.
So please help me for solving this issue.
Thanks,
<u><i><b>Seema.</b></i></u>Hi,
Check out this sample program for dynamictable report.
REPORT YMS_DYNAMICDEMO
NO STANDARD PAGE HEADING
MESSAGE-ID zcs_c2c_001.
type-pools : abap.
field-symbols: <dyn_table> type standard 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.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab.
perform get_data.
perform write_out.
form get_structure.
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( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
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>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
form write_out.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
endform.
Thanks,
Shankar -
How to download data from an internal table to a text
Hi All,
I want to download data from an internal table to a text file.
The fields should be pipe(|) separated. I have tried GUI_DOWNLOAD but it is not taking the field separator.
The sample of the desired data that i require should be this way:-
13456TR|M|COUP|MATERIAL|KGS
Thanks in advance.
Regards
Satish.Hi,
Try this..
REPORT zc1download message-id zc1dwnmsg.
*& Declaration Section for the Tables *
TABLES: makt.
*& Declaration Section for the Internal Tables
DATA: intab TYPE TABLE OF makt,
wa_intab LIKE LINE OF intab,
no_of_rec TYPE i,
count TYPE i.
DATA: BEGIN OF f_intab,
str(255) TYPE c,
END OF f_intab.
DATA: t_intab LIKE TABLE OF f_intab,
w_intab LIKE LINE OF t_intab,
temp(255) TYPE c.
FIELD-SYMBOLS: <f> TYPE ANY.
*& Selection ScreenSection for the file download
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: file TYPE rlgrap-filename MEMORY ID file,
tab RADIOBUTTON GROUP rad1 DEFAULT 'X',
others RADIOBUTTON GROUP rad1,
delimit TYPE c.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
IF file IS INITIAL. " check to ensure file.
MESSAGE i001.
EXIT.
ENDIF.
IF others = 'X'. " check to ensure delimiter.
IF delimit = ' '.
MESSAGE i002.
EXIT.
ENDIF.
ENDIF.
SELECT * FROM makt INTO TABLE intab.
IF tab = 'X'. " default delimiter tab is used
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'DAT'
mode = 'A'
TABLES
data_tab = intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE. " If user defind delimiter is to be used
Counts the number of fields *
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
IF sy-subrc <> 0.
EXIT.
ELSE.
count = count + 1.
ENDIF.
ENDDO.
LOOP AT intab INTO wa_intab.
DO count TIMES. " Adding the delimiter in required places
ASSIGN COMPONENT sy-index OF STRUCTURE wa_intab TO <f>.
CONCATENATE temp delimit <f> INTO temp.
ENDDO.
SHIFT temp.
APPEND temp TO t_intab.
CLEAR temp.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = file
filetype = 'ASC'
mode = 'A'
TABLES
data_tab = t_intab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
WRITE:/ 'The Data has been tranfered to :', file.
Cheers
Kathir!~ -
Value not moved to work are of the internal table
HI
I have one internal table declared with occurs 2500.
i am selecting the values from a z table into this internal table.
now i want to move the values in the table to another internal table for download.here except one field all the other fields are moving to the new internal table.When i debugged i could see the value in the internal table but its not getting moved to work area of that internal table (or the header line).
I could not see the value when i use itab[]-field in debugger mode instead when i use itab[1]-field i could see that field value.
please do suggest.There is no need to move your data from one internal table to another with fixed structure. All you need to do is take each row's components skipping the column you don't want to download and concatenate this to some string. Then append to string table and download it. Sample:
"let's say your column is on 3rd place in the table
data l_row_string type string.
data lt_string_tab type table of string.
Loop at itab assigning <wa>.
do.
check sy-index ne 3. "skip this column
assign component sy-index of structure <wa> to <comp>.
if sy-subrc = 0.
CONCATENATE l_row_string <comp> INTO l_row_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
else.
"no more component in row
append l_row_string to lt_string_tab.
clear l_row_string.
exit.
endif.
enddo.
endloop.
Now all you need is to downlaod your lt_string_tab as your text file (extension TXT).
Regards
Marcin -
Delete record from fileld symbol which is an internal table
Hello experts,
My requirement is like below.....
Loop at <fs_table> into <fs_wa>.
if condtion.
delete record.
endif.
endloop.
I need to delete the field-symbol (an internal table) record.
any suggestions .......... <<text removed by moderator>>
Thnanks in advance.
Zak.
Edited by: Matt on Nov 18, 2008 4:48 PM Do not offer to rewardHi,
Simply do this
TABLES : vbap, ekko, ekpo.
data : it_vbap type table of vbap.
field-symbols : <fs> type standard table,
<fs_wa> like vbap.
SELECT-OPTIONS : s_vbeln FOR vbap-vbeln MODIF ID vbe,
s_posnr FOR vbap-posnr MODIF ID vbe.
select * from vbap into table it_vbap.
assign it_vbap to <fs>.
loop at <fs> assigning <fs_wa>.
delete <fs>.
endloop.
Inside the loop you just need to specify the field symbol that points to the table , so the current line will be deleted. Because while looping, the <fs> points to the content of the current line of table it_vbap.
regards,
Advait
Edited by: Advait Gode on Nov 18, 2008 4:17 PM -
Popualting data into dynamic internal table
Hi all,
I am working on Dynamic internal tables.I have created the structure of internal table but i am unable to populate data into it.Though i have seen some of the forums but those didn't help me. please provide me the solution. Here is my code what i did.I have the data in itab and itab1.
My requirement is meinh fileds are dynamic.thie meinh and umren are two fileds in mvke table.for one record ihave to populate umren value for that particular meinh value.Pls help me.
mtart vkorg werks mtanr Meinh(kg) Meinh(gl)
fert 0353 0303 3231 Umren value Umren value
REPORT z123.
T Y P E - P O O L S
TYPE-POOLS :slis,abap.
T A B L E S
*Tables
TABLES: mara,marm,mvke,marc.
F I E L D - S Y M B O L S
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> ,
<dyn_field>.
I N T E R N A L T A B L E S
Internal Tables declaration for ALV GRID/LIST
DATA: ls_fieldcat TYPE slis_fieldcat_alv, "FIELD CATALOG LIST
tb_uom_cat TYPE slis_t_fieldcat_alv, "FIELD CATALOG
ls_fieldcat1 TYPE lvc_s_fcat,
tb_dy_cat TYPE lvc_t_fcat, "FIELD CATALOG
tb_outputcat TYPE slis_t_fieldcat_alv,
tb_events TYPE slis_t_event,
ref_grid TYPE REF TO cl_gui_alv_grid,
t_events LIKE LINE OF tb_events.
DATA: BEGIN OF itab OCCURS 0,
mtart LIKE mara-mtart,
vkorg LIKE mvke-vkorg,
werks LIKE marc-werks,
matnr TYPE mara-matnr,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
matnr TYPE marm-matnr,
umren TYPE marm-umren,
meinh TYPE marm-meinh,
END OF itab1.
V A R I A B L E S
Global Variables
DATA: g_repid LIKE sy-repid. "Report ID
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data.
S E L E C T I O N S C R E E N
For User Input(Selection Criteria)
SELECTION-SCREEN BEGIN OF BLOCK b0 WITH FRAME TITLE text-001.
SELECT-OPTIONS :
s_mtart FOR mara-mtart OBLIGATORY, " Material type
s_vkorg FOR mvke-vkorg OBLIGATORY, " Sales Organization
s_plant FOR marc-werks, " Plant
s_meinh FOR marm-meinh. " Unit of Measure
SELECTION-SCREEN END OF BLOCK b0.
I N I T I A L I Z A T I O N
INITIALIZATION.
Program ID
g_repid = sy-repid. " Prog ID
A T S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN.
Validate Material Type
PERFORM check_mtart.
Validate Sales Organization
PERFORM check_vkorg.
Validate Plant
PERFORM check_werks.
Validate Unit of Measure (UOM)
PERFORM check_meinh.
S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
Get Data
PERFORM get_data.
FIELD CATALOG FOR ALV
PERFORM fill_field_catalog_uom USING tb_uom_cat.
FIELD CATALOG FOR CREATING DYNAMIC INTERNAL TABLE
PERFORM fill_field_catalog_dy USING tb_dy_cat.
CREATING DYNAMIC INTERNAL TABLE
PERFORM dy_tab_create.
End of selection *
F O R M S
*& Form CHECK_MTART
Validate Material Type
FORM check_mtart .
Material Type
DATA :l_mtart LIKE t134-mtart.
CHECK NOT s_mtart IS INITIAL.
SELECT mtart UP TO 1 ROWS
INTO l_mtart
FROM t134
WHERE mtart IN s_mtart.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e899(mm) WITH 'Invalid Material Type'(002).
ENDIF.
ENDFORM. " CHECK_MTART
*& Form CHECK_VKORG
Validate Sales Organization
FORM check_vkorg .
Sales Oraganization
DATA :l_vkorg LIKE tvko-vkorg.
CHECK NOT s_vkorg IS INITIAL.
SELECT vkorg UP TO 1 ROWS
INTO l_vkorg
FROM tvko
WHERE vkorg IN s_vkorg.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e899(mm) WITH 'Invalid Sales Organization'(003).
ENDIF.
ENDFORM. " CHECK_VKORG
*& Form CHECK_WERKS
Validate Plant
FORM check_werks .
Plant
DATA :l_werks LIKE t001w-werks.
CHECK NOT s_plant IS INITIAL.
SELECT werks UP TO 1 ROWS
INTO l_werks
FROM t001w
WHERE werks IN s_plant.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e899(mm) WITH 'Invalid Plant'(004).
ENDIF.
ENDFORM. " CHECK_WERKS
*& Form CHECK_MEINH
Validate Unit of Measure (UOM)
FORM check_meinh .
Unit of Measure (UOM)
DATA :l_meinh LIKE t006-msehi.
CHECK NOT s_meinh IS INITIAL.
SELECT msehi UP TO 1 ROWS
INTO l_meinh
FROM t006
WHERE msehi IN s_meinh.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e899(mm) WITH 'Invalid Unit of Measure'(005).
ENDIF.
ENDFORM. " CHECK_MEINH
*& Form FILL_FIELD_CATALOG_UOM
text
FIELD CATALOG FOR ALV
FORM fill_field_catalog_uom USING l_fieldcat TYPE slis_t_fieldcat_alv.
DATA: BEGIN OF l_itab OCCURS 0,
meinh TYPE marm-meinh,
END OF l_itab.
DATA: l_count TYPE i.
DATA: l_fieldcat_col_pos TYPE i.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MTART'.
ls_fieldcat-key = ''.
ls_fieldcat-col_pos = 1.
ls_fieldcat-ref_fieldname = 'MTART'.
ls_fieldcat-ref_tabname = 'MARA'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VKORG'.
ls_fieldcat-key = ''.
ls_fieldcat-col_pos = 2.
ls_fieldcat-ref_fieldname = 'VKORG'.
ls_fieldcat-ref_tabname = 'MVKE'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-key = ''.
ls_fieldcat-col_pos = 3.
ls_fieldcat-ref_fieldname = 'WERKS'.
ls_fieldcat-ref_tabname = 'MARC'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-key = 'x'.
ls_fieldcat-col_pos = 4.
ls_fieldcat-ref_fieldname = 'MATNR'.
ls_fieldcat-ref_tabname = 'MARA'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
l_fieldcat_col_pos = 5.
Getting the UOM as per user selection
SELECT msehi FROM t006
INTO TABLE l_itab
WHERE msehi IN s_meinh.
LOOP AT l_itab.
ls_fieldcat-fieldname = l_itab-meinh.
ls_fieldcat-key = ''.
ls_fieldcat-col_pos = l_fieldcat_col_pos.
ls_fieldcat-ref_fieldname = 'MSEHI'.
ls_fieldcat-ref_tabname = 'T006'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
l_fieldcat_col_pos = l_fieldcat_col_pos + 1.
ENDLOOP.
ENDFORM. " FILL_FIELD_CATALOG_UOM
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM display_data .
ENDFORM. " DISPLAY_DATAENDFORM. " FILL_FIELD_CATALOG_UOM
*& Form DY_TAB_CREATE
text
--> p1 text
<-- p2 text
FORM dy_tab_create .
CREATE DYNAMIC INTERNAL TABLE AND ASSIGN TO FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = tb_dy_cat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
*CREATE DYNAMIC WORK AREA AND AASIGN TO FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. " DY_TAB_CREATE
*& Form FILL_FIELD_CATALOG_DY
text
FIELD CATALOG FOR CREATING A DYNAMIC TABLE
FORM fill_field_catalog_dy USING l_fieldcat TYPE lvc_t_fcat.
DATA: BEGIN OF l_itab OCCURS 0,
meinh TYPE marm-meinh,
END OF l_itab.
DATA: l_count TYPE i.
DATA: l_fieldcat_col_pos TYPE i.
DATA: l_umren TYPE string.
DATA: l_var TYPE string.
CLEAR ls_fieldcat.
ls_fieldcat1-fieldname = 'MTART'.
ls_fieldcat1-key = ''.
ls_fieldcat1-col_pos = 1.
ls_fieldcat1-datatype = 'char'.
ls_fieldcat1-intlen = 4.
APPEND ls_fieldcat1 TO l_fieldcat.
CLEAR ls_fieldcat1.
ls_fieldcat1-fieldname = 'VKORG'.
ls_fieldcat1-key = ''.
ls_fieldcat1-col_pos = 2.
ls_fieldcat1-datatype = 'char'.
ls_fieldcat1-intlen = 4.
APPEND ls_fieldcat1 TO l_fieldcat.
CLEAR ls_fieldcat1.
ls_fieldcat1-fieldname = 'WERKS'.
ls_fieldcat1-key = ''.
ls_fieldcat1-col_pos = 3.
ls_fieldcat1-datatype = 'char'.
ls_fieldcat1-intlen = 4.
APPEND ls_fieldcat1 TO l_fieldcat.
CLEAR ls_fieldcat1.
ls_fieldcat1-fieldname = 'MATNR'.
ls_fieldcat1-key = 'x'.
ls_fieldcat1-col_pos = 4.
ls_fieldcat1-datatype = 'char'.
ls_fieldcat1-intlen = 18.
APPEND ls_fieldcat1 TO l_fieldcat.
CLEAR ls_fieldcat1.
l_fieldcat_col_pos = 5.
Getting the UOM as per user selection
SELECT msehi FROM t006
INTO TABLE l_itab
WHERE msehi IN s_meinh.
SORT l_itab ASCENDING.
DESCRIBE TABLE l_itab LINES l_count.
LOOP AT l_itab.
ls_fieldcat1-fieldname = l_itab-meinh.
ls_fieldcat1-key = ''.
ls_fieldcat1-col_pos = l_fieldcat_col_pos.
ls_fieldcat1-datatype = 'dec'.
ls_fieldcat1-intlen = 5.
APPEND ls_fieldcat1 TO l_fieldcat.
CLEAR ls_fieldcat1.
l_fieldcat_col_pos = l_fieldcat_col_pos + 1.
ENDLOOP.
ENDFORM. " FILL_FIELD_CATALOG_DY
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM get_data .
SELECT
amtart bvkorg cwerks amatnr
INTO TABLE itab
FROM mara AS a
JOIN mvke AS b ON bmatnr = amatnr
JOIN marc AS c ON cmatnr = bmatnr
JOIN marm AS d ON dmatnr = cmatnr
WHERE a~mtart IN s_mtart
AND b~vkorg IN s_vkorg
AND c~werks IN s_plant.
SORT itab ASCENDING.
DELETE ADJACENT DUPLICATES FROM itab.
SELECT matnr umren meinh FROM marm
APPENDING TABLE itab1
FOR ALL ENTRIES IN itab
WHERE matnr = itab-matnr
AND meinh IN s_meinh .
ENDFORM. " GET_DATAcan you check this for creation of dynamic table
******DATA DECLARATION*****************************
FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
<wa_final> TYPE ANY,
<w_field> TYPE ANY.
***DYNAMIC CREATION OF FIELDCATALOG****************
*FIRST 2 FIELDS FIELDS FIELD1 AND FIELD2 ARE CONSTANT, FIELDS OBTAINED IN THE LOOP ENDLOOP ARE DYNAMIC,
*LIKEWISE DYNAMIC FIELDCATALOG IS CREATED
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'FIELD1'.
wa_fieldcatalog-ref_table = 'E070'.
wa_fieldcatalog-outputlen = '13'.
wa_fieldcatalog-reptext = 'Created On'.
wa_fieldcatalog-seltext = 'Created On'.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR wa_fieldcatalog.
LOOP AT it_mandt WHERE mandt IN s_mandt.
CONCATENATE 'CLNT' it_mandt INTO wa_fieldcatalog-fieldname.
wa_fieldcatalog-inttype = 'NUMC'.
wa_fieldcatalog-outputlen = '14'.
wa_fieldcatalog-reptext = it_mandt.
wa_fieldcatalog-seltext = it_mandt.
APPEND wa_fieldcatalog TO it_fieldcatalog.
CLEAR :wa_fieldcatalog ,it_mandt.
ENDLOOP.
********CREATE DYNAMIC TABLE************************
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = new_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN new_table->* TO <it_final>.
*********CREATE WORK AREA****************************
CREATE DATA new_line LIKE LINE OF <it_final>.
ASSIGN new_line->* TO <wa_final>.
*********INSERTTING WORK AREAR TO INTERNAL TABLE******
INSERT <wa_final> INTO TABLE <it_final>.
*******POPULATING DATA*******************************
LOOP.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
<w_field> = '21453DD'.
FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
ENDLOOP.
ENDLOOP. -
Select data into deep internal table
Dear Experts.
I created a dynamiv deep internal table.
while selecting data , into the internal table it is giving a dump. saying that deep structure.
SELECT OBJTY OBJID ARBPL WERKS from crhd
INTO CORRESPONDING FIELDS OF TABLE <f_tab>
where WERKS = pr_werks.
I used the field catalog also.even same error is comming.
how to get data into deep internal table by select statement.
Please help me,
Regards,
RahulHI,
Try creating dynamic internal table like:
Field-symbols: <dyn_table> type standard table,
<dyn_wa> ,
<dyn_field>.
Data: dy_table type ref to data,
ifc type lvc_t_fcat ,
xfc type lvc_s_fcat ,
Count type i ,
Count1 type i ,
Index type i ,
dy_line type ref to data.
Data counter type i.
Data: line type string ,
List like table of line.
Data: idetails type abap_compdescr_tab,
xdetails type abap_compdescr .
Data: ref_table_des type ref to cl_abap_structdescr.
*Looping at field cat internal table to populate another field cat to be passed
* In method used below for creating final dynamic internal table
Loop at fieldcat into fieldcat1.
Clear xfc.
Xfc-fieldname = fieldcat1-fieldname.
Xfc-datatype = fieldcat1-datatype.
Xfc-intlen = fieldcat1-intlen.
Append xfc to ifc.
endloop.
Clear fieldcat1.
*Method called to create dynamic internal table on the basis of field catalog created above
Call method cl_alv_table_create=>create_dynamic_table
Exporting
it_fieldcatalog = ifc u201Cfield catalog appended above
Importing
ep_table = dy_table. u201CDynamic internal table which will be created
Assign dy_table->* to <dyn_table>.
*Create dynamic work area and assign to FS
Create data dy_line like line of <dyn_table>.
Assign dy_line->* to <dyn_wa>.
Then use this dynamic internal table created from above method
in the Select Query.
Hope it helps
Regards
Mansi -
How to get data from an internal table in some other program
I would like to get data from the internal table in the other program. When I using FM "LIST_FROM_MEMORY" to get the data, it doesn't work and the exception is not fount.
If any special code need in the other program, like write data to memory .
Many thx .
From Ross WangHi
<li>You need to have interaction if you want to use EXPORT/IMPORT statments.
<li>The internal tables in both programs must be same
<li>Program one ..Calling program
REPORT ZTEST_NOTEPAD.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
START-OF-SELECTION.
SUBMIT ztest_notepad1 AND RETURN.
IMPORT it_t001 FROM MEMORY ID 'ZTEST_T100'.
LOOP AT it_t001.
WRITE:/ it_t001.
ENDLOOP.
<li>Program two ...Called program
REPORT ztest_notepad1.
DATA: BEGIN OF it_t001 OCCURS 0,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_t001.
START-OF-SELECTION.
SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_t001 UP TO 10 ROWS.
IF sy-dbcnt > 1.
EXPORT it_t001 TO MEMORY ID 'ZTEST_T100'.
ENDIF.
I hope that it gets you some idea.
Thanks
Venkat.O
Maybe you are looking for
-
Using map image in address book
I would like to use a map image of a persons address as their photo in address book. I have done this before but have forgotten how to do it again. I click on a contacts address and it takes me to the pre loaded map app on my ipod touch. I want to sa
-
HT201304 In App purchase failure
Why do I receive, "in App apurchase Failure"? when I buy From iTunes or App Store my purchases are successful but when using the In App purchase they fail.
-
I have tried everything I know, but can't locate the catalog- I do not know where it is or what it would be named or what carbonite would call it. Also, the photos are not at the "same" location. I have over 22,000 photos and can't imagine trying to
-
I have 3 mail apps how do I delete 2 of them
I have 3m Gmail apps hoe do I delete 3of them
-
I set up another user but it doesn't show up to login.