Internal table population
Here in this code the internal table it_mseg and it_mbew
are not being populated in the following code.Can anybody please tell me what the reason.
Thanks and regards
jyoti
SELECT mblnr
bwart
matnr
INTO TABLE it_mseg
FROM mseg.
IF it_mseg IS NOT INITIAL .
SELECT mblnr
bldat
INTO TABLE it_mkpf
FROM mkpf
FOR ALL ENTRIES IN it_mseg
WHERE mblnr = it_mseg-mblnr.
ENDIF.
IF it_mseg IS NOT INITIAL.
SELECT matnr
bwkey
bwtar
lbkum
INTO TABLE it_mbew
FROM mbew
FOR ALL ENTRIES IN it_mseg
WHERE matnr = it_mseg-matnr.
ENDIF.
Hi,
Syntax of IF it_mseg IS NOT INITIAL is wrong
Please check this code.
DATA:it_mseg LIKE MSEG OCCURS 0 WITH HEADER LINE,
it_mkpf LIKE MKPF OCCURS 0 WITH HEADER LINE,
it_mbew LIKE MBEW OCCURS 0 WITH HEADER LINE.
SELECT mblnr bwart matnr
INTO CORRESPONDING FIELDS OF TABLE it_mseg
FROM mseg.
<b>IF NOT it_mseg[] IS INITIAL .</b>
SELECT mblnr
bldat
INTO CORRESPONDING FIELDS OF TABLE it_mkpf
FROM mkpf
FOR ALL ENTRIES IN it_mseg
WHERE mblnr = it_mseg-mblnr.
ENDIF.
IF not it_mseg IS INITIAL.
SELECT matnr
bwkey
bwtar
lbkum
INTO CORRESPONDING FIELDS OF TABLE it_mbew
FROM mbew
FOR ALL ENTRIES IN it_mseg
WHERE matnr = it_mseg-matnr.
ENDIF.
Similar Messages
-
Populating one Internal table from two internal tables.
Hello Gurus,
iam having 3 internal table with same structure ,
1st internal table having some records
2nd internal table is also having some records
what i need to do is to populate the records to the 3rd internal table which the common records in the 1st and 2nd internal table. (common means intersection).
please explain how and using which concept and if possible code also...
Regards,
Ravi.hi ravi,
look at the folowing code for reference
*&--mard structure
types: begin of struc_mard,
matnr type matnr, "Material Number
werks type werks_d, "Plant
lgort type lgort_d, "Storage Location
labst type labst, "Valuated stock with unrestricted use
end of struc_mard.
*&--mara structure
types: begin of struc_mara,
matnr type matnr, "material number
meins type meins, "unit of measurement
mtart type mtart, "material type
ersda type ersda, "Creation date
end of struc_mara.
*&--maktx structure
types: begin of struc_maktx,
matnr type matnr, "material number
maktx type maktx, "material description
end of struc_maktx.
*&--Final structure
types: begin of struc_final,
matnr type matnr, "Material Number
werks type werks_d, "Plant
lgort type lgort_d, "Storage Location
labst type labst, "Valuated stock with unrestricted use
meins type meins, "unit of measurement
mtart type mtart, "material type
ersda type ersda, "Creation date
maktx type maktx, "material description
v_box(1) type c, "for checkbox field
end of struc_final.
*&---work area for Internal Tables[population 1]
data: wa_mard type struc_mard,
wa_mara type struc_mara,
wa_maktx type struc_maktx,
wa_final type struc_final.
INTERNAL TABLES DECLARATION *
*&---Internal tables for storing data.[populaiton 1]
data: i_mard type standard table of struc_mard,
i_mara type standard table of struc_mara,
i_maktx type standard table of struc_maktx,
i_final type standard table of struc_final.
*&--fetching the data from table for storage
select matnr
werks
lgort
labst
into table i_mard
from mard
where matnr in r_matnr and werks in r_werks and lgort in
r_lgort
if sy-subrc <> 0. "if unsuccesful
message e004. "Error- Record does not exist
endif.
selection of material description
if i_mard[] is not initial.
*SELECT DISTINCT FOR UNIQUE ENTRIES ONLY
select distinct matnr
maktx
into table i_maktx
from makt
for all entries in i_mard
where matnr = i_mard-matnr and
spras = sy-langu.
if sy-subrc <> 0. " if unsucessful
wa_maktx-maktx = text-028. "NO DESCRIPTION
endif.
*fetching information from material master
select distinct matnr
meins
mtart
ersda
into table i_mara
from mara for all entries in i_mard
where matnr = i_mard-matnr.
if sy-subrc <> 0.
message e003.
endif.
*&--sorting the tables
sort: i_mard by matnr werks lgort,
i_mara by matnr,
i_maktx by matnr.
*&--Clearing workareas.
clear: wa_mard,
wa_mara,
wa_maktx,
wa_final.
*PROCESSING
loop at i_mard into wa_mard.
*moving values to final workarea
wa_final = wa_mard.
at new matnr.
read table i_maktx into wa_maktx
with key matnr = wa_mard-matnr binary search.
read table i_mara into wa_mara
with key matnr = wa_mard-matnr binary search.
endat.
if sy-subrc = 0.
"if succesful then move to final workarea
wa_final-maktx = wa_maktx-maktx.
*for mara values
wa_final-meins = wa_mara-meins.
wa_final-mtart = wa_mara-mtart.
wa_final-ersda = wa_mara-ersda.
endif.
*append final workarea
append wa_final to i_final.
endloop.
clearing and refreshing the table I_MARD
refresh: i_mard.
clear: wa_mard.
endif.
endform. "zf_populate_info
this will move all the data into final table you have got, with the performnce tuned way
reward point if useful
Rohan malik -
Moving data from one internal table to another
Hi,
I have one internal table populated with a list of material codes and another with all the material numbers.
ITAB1: MCODE KSCHL KNUMH MATNR
ITAB2: MCODE MATNR
The matnr field in itab1 is blank initially. It needs to be populated with all the material numbers from itab2. How can I achieve this?
Thanks,
apHi
Lets say that there is only one record in itab1 and for that there is correspondingly 10 records in itab2.
that means that the one record in itab1 should be changed to the first material number in itab2 and there should be nine more records created in itab1 according to the values in itab2.
Hope this is what you mean.
If this is the logic then the following code should work
then lets have a third internal table the same type as itab1
Loop at itab1 into wa_itab1
*readt table itab2 into wa_itab2 with key mcode = wa_itab1-mcode.
*IF sy-subrc eq 0.
loop at itab2 into wa_itab2 where mcode = wa_itab1-mcode.
wa_itab1-matnr = wa_itab2-matnr
append wa_itab1 to itab3.
endloop.
*ENDIF.
*modify itab1 from wa_itab1.
endloop.
itab3 will contain all the values that you require -
Dynamic Internal Table creation and population
Hi gurus !
my issue refers to the slide 10 provided in this slideshow : https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae
My example is gonna sound dumb, but anyway: I want to dynamically select from a table into a dynamically created itab.
Letu2019s use only EKPO, and only field MENGE.
For this, I use Classes cl_abap_elemdescr, cl_sql_result_set and the Data Ref for table creation. But while fetching the resultset, program dumps when fields like MENGE, WRBTR are accessed. Obviously their type are not correctly taken into account by my program.
Here it comes:
DATA: element_ref TYPE REF TO cl_abap_elemdescr,
vl_fieldname TYPE string,
tl_components TYPE abap_component_tab,
sl_components LIKE LINE OF tl_components_alv,
linetype_lcl TYPE REF TO cl_abap_structdescr,
ty_table_type TYPE REF TO cl_abap_tabledescr,
g_resultset TYPE REF TO cl_sql_result_set
u2026
CONCATENATE sg_columns-table_name '-' sg_columns-column_name INTO vl_fieldname.
* sg_columns-table_name contains 'EKPO'
* sg_columns-column_name contains 'MENGE'
* getting the element as a component
element_ref ?= cl_abap_elemdescr=>describe_by_name( vl_fieldname ).
sl_components-name = sg_columns-column_name.
sl_components-type ?= element_ref.
APPEND sl_components TO tl_components.
* dynamic creation of internal table
linetype_lcl = cl_abap_structdescr=>create( tl_components ).
ty_table_type = cl_abap_tabledescr=>create(
p_line_type = linetype_lcl ).
u2026
* Then I will create my field symbol table and line. Code has been cut here.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
u2026
* Then I will execute my query. Here itu2019s: Select MENGE From EKPO Where Rownum = 1.
g_resultset = g_stmt_ref->execute_query( stmt_str ).
* Then structure for the Resultset is set
CALL METHOD g_resultset->set_param_struct
EXPORTING
struct_ref = dy_line.
* Fetching the lines of the resultset => Dumpu2026
WHILE g_resultset->next( ) > 0.
ASSIGN dy_line->* TO <dyn_wa>.
APPEND <dyn_wa> TO <dyn_table>.
ENDWHILE.
Anyone has any clue to how prevent my Dump ??
The component for MENGE seems to be described as a P7 with 2 decimals. And the resultset wanna use a QUAN type... or something like that !Hello
I have expanded your sample coding for selecting three fields out of EKPO:
*& Report ZUS_SDN_SQL_RESULT_SET
*& Thread: Dynamic Internal Table creation and population
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1375510"></a>
*& NOTE: Coding for dynamic structure / itab creation taken from:
*& Creating Flat and Complex Internal Tables Dynamically using RTTI
*& https://wiki.sdn.sap.com/wiki/display/Snippets/Creating+Flat+and+
*& Complex+Internal+Tables+Dynamically+using+RTTI
REPORT zus_sdn_sql_result_set.
TYPE-POOLS: abap.
DATA:
go_sql_stmt TYPE REF TO cl_sql_statement,
go_resultset TYPE REF TO cl_sql_result_set,
gd_sql_clause TYPE string.
DATA:
gd_tabfield TYPE string,
go_table TYPE REF TO cl_salv_table,
go_sdescr_new TYPE REF TO cl_abap_structdescr,
go_tdescr TYPE REF TO cl_abap_tabledescr,
gdo_handle TYPE REF TO data,
gdo_record TYPE REF TO data,
gs_comp TYPE abap_componentdescr,
gt_components TYPE abap_component_tab.
FIELD-SYMBOLS:
<gs_record> TYPE ANY,
<gt_itab> TYPE STANDARD TABLE.
START-OF-SELECTION.
continued. -
Populating two dynamic internal tables and displaying the O/p as ALV
I want to develop a abap prototype program report for the SD document flow analysis...
There is a Fm : RV_ORDER_FLOW_INFORMATION in which if we pass the Sales order number it returns the flows as VBFA_TAB.
I need to populate two dynamic ITAB1 and ITAB2
the structure of ITAB1 should be like ColNm1....ColNmn
The values for ColNm1 will be Sales Order ColNm2 as Delivery or smthng else depending on field vbtyp_n.
ITAB 2 should have the corresponding values accly to ITAB1.
Then we need to display in ALV o/p.
The tables should be populated dynamically.
Can anybody throw some light on it and plz do write back with sample code to do the logic of it.Search in SDN with Dynamic internal tables.
you get lot of code samples and Discussions related to Dynamic internal tables.
you can also check with this class CL_ALV_TABLE_CREATE -
Issue In internal table data population in the o/p
Dear Guru , I have encountered an issue for which i am not able to findout the logic . I have an internal table through which i am populating the below data for detail report format :->
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
019 0820B0073 MOD3 101 space
020 0820B0074 MOD4 101 space
020 0820B0074 MOD4 101 2
020 0820B0074 MOD4 101 3
The requirment is like this the summary report should show o/p like below addition of all the rows with respect to plant , material, storage location and movement type :-
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 space
020 0820B0074 MOD4 101 5
but when i am adding it with respect to plant, material, storage location and movement type the o/p i am getting is like below
Plant Material Number Storage Loc Movement Type Avg Days
019 0820B0073 MOD3 101 0
020 0820B0074 MOD4 101 5
becasue addition of 5 spaces ( Avg Days )of plant 019 is coming as ZERO --> 0
so Guru what logic i should use to get the proper o/p,..I have Used Following logic to perform summation with respect to plant, material , storage loc and movement type.
CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.
LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.
IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.
CLEAR: wa_p_coi.
READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.
IF sy-subrc = 0.
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .
CLEAR: wa_p_coi, wa_p_coi.
endif.
ELSE.
wa_p_coi-werks = wa_mkpf_mseg-werks.
wa_p_coi-matnr = wa_mkpf_mseg-matnr.
wa_p_coi-bwart = wa_mkpf_mseg-bwart.
wa_p_coi-lgort = wa_mkpf_mseg-lgort.
wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .
APPEND wa_p_coi TO t_p_coi.
CLEAR: wa_p_coi.
ENDIF.
w_werks = wa_mkpf_mseg-werks.
w_matnr = wa_mkpf_mseg-matnr.
w_lgort = wa_mkpf_mseg-lgort.
w_bwart = wa_mkpf_mseg-bwart.
CLEAR: wa_mkpf_mseg.
ENDLOOP.The soln what i found after working out
CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.
LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.
IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.
CLEAR: wa_p_coi.
READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.
IF sy-subrc = 0.
if wa_p_coi-Avg Days = ' ' and wa_mkpf_mseg-Avg Days = ' '.
wa_p_coi-Avg Days = ' '.
ELSE
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
Endif.
MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .
CLEAR: wa_p_coi, wa_p_coi.
endif.
ELSE.
wa_p_coi-werks = wa_mkpf_mseg-werks.
wa_p_coi-matnr = wa_mkpf_mseg-matnr.
wa_p_coi-bwart = wa_mkpf_mseg-bwart.
wa_p_coi-lgort = wa_mkpf_mseg-lgort.
wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .
APPEND wa_p_coi TO t_p_coi.
CLEAR: wa_p_coi.
ENDIF.
w_werks = wa_mkpf_mseg-werks.
w_matnr = wa_mkpf_mseg-matnr.
w_lgort = wa_mkpf_mseg-lgort.
w_bwart = wa_mkpf_mseg-bwart.
CLEAR: wa_mkpf_mseg.
ENDLOOP. -
Populating Empty Fields for Existing Internal Table Using For All Entries
I have an internal table called itab_extract that populates without any issues in SELECT A and SELECT B below. Trying to avoid looping, I am using select DB table 'for all entries' in itab_extract. I want the empty fields in itab_extract to populate from the values in the database. However, about 200,000 entries are being appended to the table, and, the values that existed for the already populated fields in itab_extract are gone, and the new fields are populated.
I've played with the syntax and cannot seem to get it to work. My next option is a time consuming loop.
How should the for all entries syntax look to accomplish filling the empty fields in the itab? Thank-You
*read ekko
select ebeln lifnr aedat bsart from ekko *SELECT A*
into CORRESPONDING FIELDS OF TABLE me->itab_extract
where aedat in r_aedat.
select ebeln lifnr aedat BSART from ekko *SELECT B*
appending CORRESPONDING FIELDS OF TABLE me->itab_extract
where aedat in S_DATE2 AND
BSART IN S_BSART.
select ebelp werks matnr *SELECT C*
into CORRESPONDING FIELDS OF TABLE itab_extract
from ekpo
FOR ALL ENTRIES IN itab_extract
where ebeln = itab_extract-ebeln.Hi Tom,
This SQL statement will be time consuming, Do not use a loop.
There are two options.
1. Select EKKO and EKPO details based on standard SAP view. (You can type EKKO in se11 view to find the correct view).
also use one range table populate r_aedat and s_date2 in the same. So you where condition will have r_newrange and
s_bsart. Also do not use into corresponding fields, it is not a good idea. It will increase your performance. Maintain the proper
sequence (Based on database structure of EKKO and EKPO)
2. If you are keen to use for all entries, then first select ekko then after your sy-subrc check get the data from EKPO.
Should be like this.
select ebeln bsart aedat lifnr from ekko into table gt_ekko where aedat in r_newrange and bsart in s_bsart.
if sy-subrc eq 0.
sort gt_ekko by ebeln ascending.
select ebeln ebelp werks matnr into table gt_ekpo for all entries in gt_ekko where ebeln eq gt_ekko-ebeln.
endif.
Hope it helps,
Best Regards,
Tapodipta Khan. -
Populating values to internal table created dynamically
Hi,
I am creating an internal table(it1) dynamically and assigned it to a field symbol. now i want to upload values
which are present in a field of another internal table being populated from a Funct Module.Could you tell me
how to assign those values across the fields of field symbol?
loop at itab_char.
LS_ALV_CAT-FIELDNAME = itab_char-charact.
append LS_ALV_CAT to I_ALV_CAT.
endloop.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = I_ALV_CAT
IMPORTING
EP_TABLE = D_REF.
ASSIGN D_REF->* TO <F_FS>.
(Above my int tab is generated and now stored in <f_FS>)
loop at itab into w_lifnr.
CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
EXPORTING
CLASS = p_cname
CLASSTYPE = w_ctype
OBJECT = w_lifnr
TABLES
T_CLASS = t_class
T_OBJECTDATA = t_objectdata
w-lifnr is vendor number. and here we are populating t_objectdata with that vendor related datas. now i want to pass t_objectdata-ausp1 values for each vendor across the fields in <F_FS>.
FIELD-SYMBOLS : <F_FS> TYPE TABLE.
Please refer me the solution to this problem.
ThanksCheck below code and try to add in ur code....
IF NOT it_bom_expl[] IS INITIAL.
The material number data varies from run to run. For this purpose
the data is been used to build dynamic internal table which stores the
material number data along the x-axis
PERFORM build_matnr_table.
The material numbers data which is stored in the temp internal table
is been assigned to the dynamic internal table created along the
x-axis for the materials
PERFORM assign_matnr_val_fields.
The component data which is stored in the internal table needs to be
moved to the dynamic internal table
PERFORM move_bom_data_to_matnr_table.
*& Form build_matnr_table
Using the material number data the dynamic internal tables are been
built which holds the material number data along x-axis. Here the
first 3 columns are always constant which are Components-List,
Description, Count. From 4th column it depends on number of materials
FORM build_matnr_table .
DATA: l_val(3) TYPE n,
lf_mat(18) TYPE c.
Moving the Components-List details to the internal table 1st column
which will be used for creation of dynamic internal table
CLEAR gf_xfc.
gf_xfc-fieldname = text-t03.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 18.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
APPEND gf_xfc TO gf_ipc.
CLEAR gf_xfc.
Moving the Description details to the internal table 2nd column
which will be used for creation of dynamic internal table
gf_xfc-fieldname = text-t04.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 40.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ipc.
CLEAR gf_xfc.
Moving the Count details to the internal table 3rd column which will
be used for creation of dynamic internal table
gf_xfc-fieldname = text-t05.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 5.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
APPEND gf_xfc TO gf_ipc.
Moving the Material numbers are moved to the internal table from 4th
column onwards till all the material numbers are moved to the columns
which will be used for creation of dynamic internal table. Here
columns will be reffered to as Material001 ..... Materialxxn
LOOP AT it_mat.
CLEAR gf_xfc.
l_val = l_val + 1.
CONCATENATE text-t06 l_val INTO lf_mat.
gf_xfc-fieldname = lf_mat.
gf_xfc-datatype = c_val_c.
gf_xfc-inttype = c_val_c.
gf_xfc-intlen = 18.
gf_xfc-decimals = 0.
APPEND gf_xfc TO gf_ifc.
APPEND gf_xfc TO gf_ipc.
ENDLOOP.
Using the above data dynamic internal table is been created
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gf_ifc
IMPORTING
ep_table = gf_table.
The dynamic internal table which is created is been assigned to
field-symbol which holds the data of the columns of X-axis
ASSIGN gf_table->* TO <fs_dyn_table>.
Dynamic work area is been created usng the reference to the
field-symbol which has the data and the line item is been assign to
field-symbol to hold line item data for reading purposes line by line
CREATE DATA gf_line LIKE LINE OF <fs_dyn_table>.
ASSIGN gf_line->* TO <fs_dyn_wa>.
Using the above data dynamic internal table is been created
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gf_ipc
IMPORTING
ep_table = gf_table1.
The dynamic internal table which is created is been assigned to
field-symbol which holds the data of the columns of X-axis
ASSIGN gf_table1->* TO <fs_dyn_table1>.
Dynamic work area is been created usng the reference to the
field-symbol which has the data and the line item is been assign to
field-symbol to hold line item data for reading purposes line by line
CREATE DATA gf_line1 LIKE LINE OF <fs_dyn_table1>.
ASSIGN gf_line1->* TO <fs_dyn_wa1>.
Using the above data dynamic internal table is been created
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gf_ifc
IMPORTING
ep_table = gf_table2.
The dynamic internal table which is created is been assigned to
field-symbol which holds the data of the columns of X-axis
ASSIGN gf_table2->* TO <fs_dyn_table2>.
Dynamic work area is been created usng the reference to the
field-symbol which has the data and the line item is been assign to
field-symbol to hold line item data for reading purposes line by line
CREATE DATA gf_line2 LIKE LINE OF <fs_dyn_table2>.
ASSIGN gf_line2->* TO <fs_dyn_wa2>.
ENDFORM. " build_matnr_table
*& Form assign_matnr_val_fields
The material numbers data stored in the temp internal table needs to
be assigned to the dynamic internal table along x-axis as the first
record. The temp internal table is been looped and using the field
symbol concept the data is moved to the dynamic internal table
FORM assign_matnr_val_fields .
DATA: l_cnt(3) TYPE n,
l_nam(12),
g_total(3) TYPE n.
DESCRIBE TABLE it_mat LINES g_total.
CLEAR l_cnt.
Looping the temp internal table and concatenating material as
material001 and the same is been checked against the dynamic
internal table and the material number value is moved to the
internal table. Finally, the data is been appened as first record.
LOOP AT it_mat.
l_nam = c_mat.
l_cnt = l_cnt + 1.
CONCATENATE l_nam l_cnt INTO l_nam.
Material which is in form Materialxxn is been assigned to the field
symbol which is checked against the field of dynamic internal table
and the value of the Material Number is been passed to the dynamic
internal table field value.
After all materials are been assigned the record is been appended
to the dynamic internal table.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_field>.
<fs_field> = it_mat-matnr.
IF l_cnt = g_total.
INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
ENDIF.
ENDLOOP.
Looping the temp internal table and concatenating material as
material001 and the same is been checked against the dynamic
internal table and the material number value is moved to the
internal table. Finally, the data is been appened as first record.
This is been used for downloading of data to excel sheet as it
contains additional field which is Description field.
CLEAR l_cnt.
LOOP AT it_mat.
l_nam = c_mat.
l_cnt = l_cnt + 1.
CONCATENATE l_nam l_cnt INTO l_nam.
Material which is in form Materialxxn is been assigned to the field
symbol which is checked against the field of dynamic internal table
and the value of the Material Number is been passed to the dynamic
internal table field value.
After all materials are been assigned the record is been appended
to the dynamic internal table.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa1> TO <fs_field>.
<fs_field> = it_mat-matnr.
IF l_cnt = g_total.
INSERT <fs_dyn_wa1> INTO TABLE <fs_dyn_table1>.
ENDIF.
ENDLOOP.
The contents of one internal table is passed on to other internal
table for use while moving the component data for count purposes.
<fs_dyn_table2>[] = <fs_dyn_table>[].
ENDFORM. " assign_matnr_val_fields
*& Form move_bom_data_to_matnr_table
The component data is been appended to the dynamic internal table
The component is checked against a material and if exists the corresp-
onding level is been appended to the record
The total count is derived as the in how many materials the component
exists
FORM move_bom_data_to_matnr_table .
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.
Looping the component internal table. This is used for the additional
Description field which is shown in the excel sheet
LOOP AT it_bom_expl INTO gf_it_bom_expl.
CLEAR: l_cnt1.
AT NEW bom_comp.
CLEAR: l_cnt, <fs_dyn_wa1>, 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_wa1> 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_wa1> 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.
The description 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_description OF STRUCTURE <fs_dyn_wa1> TO
<fs_check>.
<fs_check> = gf_it_bom_expl-ojtxp.
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.
AT END OF bom_comp.
ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa1> TO <fs_check>.
<fs_check> = l_cnt.
INSERT <fs_dyn_wa1> INTO TABLE <fs_dyn_table1>.
ENDAT.
ENDLOOP.
ENDFORM. " move_bom_data_to_matnr_table -
Populating values in dynamically generated internal table
Hi,
We can generate internal tables dynamically and also populate them with values from database.But is there any way to populate the dynamically generated internal table(has 2-3 selected fields) with values from another internal table(has all fields required by the program) being populated within the same program?
Thanks & Regards,
SavithaHi
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
Reward points if useful
Regards
Anji -
Data populated in internal Table its not diplay in result
Hi ABAPers,
i have one doubt in internal table one field data is populated but in result its diplayed. can any one tell me the solution for this
regards,
kishore.hi this is a simple report on internal table.
REPORT zvenkattest0.
TABLES:pa0002,pa0008.
data:begin of it_pa0002 occurs 0,
pernr like pa0002-pernr,
begda like pa0002-begda,
endda like pa0002-endda,
vorna like pa0002-vorna,
nachn like pa0002-nachn,
end of it_pa0002.
SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
START-OF-SELECTION.
SELECT pernr
begda
endda
vorna
nachn
FROM pa0002
INTO TABLE IT_pa0002
WHERE pernr IN S_pernr.
sort it_pa0002 by pernr begda descending.
loop at it_pa0002.
write:/ it_pa0002-pernr,
it_pa0002-begda,
it_pa0002-endda,
it_pa0002-vorna,
it_pa0002-nachn.
endloop.
reward points if useful,
venkat. -
Problem populating an internal table
Hello,
I am having a problem with filling an internal table. I cannot seem to grasp this and I struggle with this in every program. I am attaching pieces of my program so that maybe someone can help me. I have a selection screen that I populate with dates. if the dates are populated, I want to use these dates for the selection. If the dates are initial, I want to read an entry from the TVARV table and populate the dates that will used in the selection. I tried various code statements and I cannot get it to work. i get messages like "is a table without a header line and therefore has no component "LOW" or other messages similar to this. I would like that if the s_udate is populated, I could fill the tvarv table and not have to call the form.
also if anyone has some documentation on working with internal tables without header lines (I think I read in here that internal tables without header lines is the way to go ), could you please include that as well so that I could try to understand how this suppose to work
thanks in advance for the help
TYPES: BEGIN OF ty_tvarv_date,
low TYPE tvarv_val, "start date
high TYPE tvarv_val, "end date
END OF ty_tvarv_date.
TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,
DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0.
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(22) text-002.
SELECT-OPTIONS s_udate FOR sy-datlo.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK a.
PERFORM select_date_tvarv CHANGING it_tvarv_date.
PERFORM select_data643_mseg USING it_tvarv_date
it_zfi_gl_subcontrk[]
CHANGING it_mseg643.
<b>*******************************************************************</b>
FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.
IF s_udate IS INITIAL.
SELECT low high
FROM tvarv
INTO TABLE p1_it_tvarv_date
WHERE name EQ 'Z_SUBCONTRK_DATES'.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ENDIF.
ELSE.
MOVE s_udate to p1_it_tvarv_date.
MOVE s_udate-low(8) to p1_it_tvarv_date-low.
MOVE s_udate-high(8) to p1_it_tvarv_date-high.
ENDIF.
ENDFORM. " FORM SELECT_DATE_TVARV
<b>*******************************************************************</b>
FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date
p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
CHANGING p1_it_mseg TYPE ty_t_mseg643.
DATA: wa_tvarv_date type ty_tvarv_date.
READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
SELECT abukrs awerks amatnr aerfmg a~erfme
akostl abwart amblnr awempf acharg akzbew algort bbudat
FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr
AND b~budat <= wa_tvarv_date-high
AND b~budat >= wa_tvarv_date-low
INTO TABLE p1_it_mseg
FOR ALL ENTRIES IN p1_zfi_gl_subcontrk
WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from
AND a~werks EQ p1_zfi_gl_subcontrk-werks_from
AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643
AND a~matnr EQ p1_zfi_gl_subcontrk-matnr
AND a~bwart EQ'643'.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ENDIF.
ENDFORM. " FORM SELECT_DATA643_MSEGIn tables with header line, you need not define an explicit work area.
System will create a so-called work area, which is called header line.
This header line is like any other work area. the difference is that it can be accessed using internal table name. A record will be by default read into header line in a READ statement.
For ex,
READ TABLE p1_tvarv_date INTO wa_tvarv_date INDEX 1.
Here you used to read the 1st record into wa_tvarv_date.
But after making it table with header line you can use
READ TABLE p1_tvarv_date INDEX 1.
This will move the data to header line and it can be accessed by name p1_tvarv_date.
See the code below.
TYPES: BEGIN OF ty_tvarv_date,
low TYPE tvarv_val, "start date
high TYPE tvarv_val, "end date
END OF ty_tvarv_date.
TYPES: ty_t_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date INITIAL SIZE 0,
DATA it_tvarv_date TYPE STANDARD TABLE OF ty_tvarv_date <b>WITH HEADER LINE INITIAL</b> SIZE 0.
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(22) text-002.
SELECT-OPTIONS s_udate FOR sy-datlo.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK a.
PERFORM select_date_tvarv CHANGING it_tvarv_date.
PERFORM select_data643_mseg USING it_tvarv_date
it_zfi_gl_subcontrk[]
CHANGING it_mseg643.
FORM select_date_tvarv CHANGING p1_it_tvarv_date TYPE ty_t_tvarv_date.
IF s_udate IS INITIAL.
SELECT low high
FROM tvarv
INTO TABLE p1_it_tvarv_date
WHERE name EQ 'Z_SUBCONTRK_DATES'.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ENDIF.
ELSE.
MOVE s_udate to p1_it_tvarv_date.
MOVE s_udate-low(8) to p1_it_tvarv_date-low.
MOVE s_udate-high(8) to p1_it_tvarv_date-high.
ENDIF.
ENDFORM. " FORM SELECT_DATE_TVARV
FORM select_data643_mseg USING p1_tvarv_date TYPE ty_t_tvarv_date
p1_zfi_gl_subcontrk TYPE ty_t_zfi_gl_subcontrk
CHANGING p1_it_mseg TYPE ty_t_mseg643.
<b>READ TABLE p1_tvarv_date INDEX 1.</b>
SELECT abukrs awerks amatnr aerfmg a~erfme
akostl abwart amblnr awempf acharg akzbew algort bbudat
FROM mseg AS a INNER JOIN mkpf AS b ON amblnr EQ bmblnr
<b>AND b~budat <= p1_tvarv_date-high
AND b~budat >= p1_tvarv_date-low</b>
INTO TABLE p1_it_mseg
FOR ALL ENTRIES IN p1_zfi_gl_subcontrk
WHERE a~bukrs EQ p1_zfi_gl_subcontrk-bukrs_from
AND a~werks EQ p1_zfi_gl_subcontrk-werks_from
AND a~wempf EQ p1_zfi_gl_subcontrk-werks_to643
AND a~matnr EQ p1_zfi_gl_subcontrk-matnr
AND a~bwart EQ'643'.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i899 WITH text-027.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e899 WITH text-027.
ENDIF.
ENDIF.
ENDFORM. " FORM SELECT_DATA643_MSEG -
Issue in populating the dynamic internal table in SMARTFORMS
Hi Experts,
My requirement is I have a table in the below format.
Measuring Point
Description of Measuring Point
UOM
Date
Time
Reading
96
POWER GENERATED
kwh
20140501
101837
1.00E+04
96
POWER GENERATED
kwh
20140502
102220
1.00E+04
96
POWER GENERATED
kwh
20140503
104623
1.25E+01
96
POWER GENERATED
kwh
20140504
101111
2.00E+03
98
AUX POWER CONSUME
kwh
20140501
101837
1.00E+05
98
AUX POWER CONSUME
kwh
20140502
102220
1.00E+05
99
NET POWER EXPORTED
kwh
20140501
101837
1.00E+07
99
NET POWER EXPORTED
kwh
20140502
102220
1.00E+07
100
AVG POWER GENERATED
MW
20140501
101837
1.00E+02
100
AVG POWER GENERATED
MW
20140502
102220
1.00E+02
101
AUX POWER CONSUMED(%)
20140501
101837
1.00E+02
101
AUX POWER CONSUMED(%)
20140502
102220
1.01E+01
102
PLANT AVAILABLE HRS
hrs
20140501
101837
1.01E+01
102
PLANT AVAILABLE HRS
hrs
20140502
102220
1.01E+01
103
PLANT RUN HOURS
hrs
20140501
101837
1.01E+01
103
PLANT RUN HOURS
hrs
20140502
102220
1.01E+01
104
PLANT AVAILABLITY FACTOR
20140501
101837
1.00E+02
104
PLANT AVAILABLITY FACTOR
20140502
102220
1.00E+02
which i need to display like below based on the user Requirement for print out.
DATE
POWER GENERATED(96)
AUX POWER CONSUME(98)
NET POWER EXPORTED(99)
AVG POWER GENERATED(100)
AUX POWER CONSUMED(%)(101)
PLANT AVAILABLE HRS(102)
PLANT RUN HOURS(103)
PLANT AVAILABLITY FACTOR(104)
kwh
kwh
kwh
MW
hrs
hrs
01.05.2014
1.00E+04
1.00E+05
1.00E+07
1.00E+02
1.00E+02
1.01E+01
1.01E+01
1.00E+02
02.05.2014
1.00E+04
1.00E+05
1.00E+07
1.00E+02
1.01E+01
1.01E+01
1.01E+01
1.00E+02
03.05.2014
1.25E+01
04.05.2014
2.00E+03
Now the issue is how to assign the values of stops from the internal table to dynamically for a specific date in SMARTFORMS?
Please help me in resolving this issue.Hi,
See if this articale is good for you:
The case of "dynamic columns in smartform"
Regards. -
hi experts,
i have a problem while using ME38 transaction.
ME38 calls exit EXIT_SAPMM06E_012
inside this exit we are calling macro mmpur_business_obj_id tekpo-id. in turn it goes to method search of class CL_HANDLE_MANAGER_MM where internal table my_items is not getting filled. due to that we are getting dump "Exception FAILURE".
Thanks in advance
Chandrahi
put break point before the step and find out the value of your table or check the paramter value you are passing -
Select statement not populating the internal table
Hi,
I have a requirement where I have to upload a file from C drive, the fields in this file are VBELN, description & date of creation.
I am able to get this file into the internal table. After this i need to cross check the VBELN against VBRK-VBELN, if present then update a Z-table.... How do I do the cross check part ?...
if not tw_zvatcn[] is initial,
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
Internal table tw_vbrk is coming blank, which is not correct because I see the data in db tbl VBRKIs p_vkorg a parameter or select option.
If it is parameter and is blank you will not get data in the table.
In that case make a condition for that field also.
if not tw_zvatcn[] is initial.
if p_vkorg is not initial.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
else.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
endif. -
Populating dynamic internal table
Hi All,
I've created a dynamic internal table the issue is that the data is to be entered in it from 2 different tables so ...
is their any way we can read the internal table field names ...
or any other way to populate data in it ...hi
check this link
http://www.****************/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
thanks
sitaram
Maybe you are looking for
-
Displaying Adobe Form through CRM WEB UI
Hi Experts, Currently I am working on CRM Technical which is very new to me. I've got a requirement to display the Adobe form through CRM WEB UI. The requirement is like this. In a screen of WEB UI there is a option of OUTPUT preview. When i select t
-
Existing IPod and new PC - How can I copy the data on my IPod onto new PC
I have hundreds of songs and photos on my IPod Touch, but the PC that I used to load them from has "died" and I cannot get access the Library's that I created on the new PC (using Vista). As most of the songs were copied from CD's (some of which I do
-
ITunes will not back up library
I have a Windows XP machine with latest version of iTunes. I have an IPOD Nano on the system, an IPOD Shuffle, and an iPhone 3GS 16gb on the system. I am trying to install a new hard drive on my desktop. I am currently trying to back everything up. I
-
Thinkpad Yoga - touch screen on left half of the screen unresponsive
Hi guys! On my new TPY the touch screen on the left hand side (the side where the charger is connected) is unresponsive. The pen however works perfectly fine. I have already run the lenovo software update tool and updated/installed all the drivers so
-
Q10 Device Wont Recognize Contacts
hello am having issues with this new blackberry Q10 and this is one of the issues blackberry wont recognize my contacts get in coming calls and i do out going calls i dont see the names of the contacts when i receive a call and i dont see the name o