Working with dynamic internal tables
Hi,
I've created dynamic internal table and then assigned it to field symbol structure.
This is part of the code.
wa_tab = cl_abap_structdescr=>create( comp_tab ).
i_tab = cl_abap_tabledescr=>create( wa_tab ).
create data i_table type handle i_tab.
assign i_table->* to <f_tab1>.
As a second step I am populationg that structure <f_tab1> with data using dynamic select:
select (sel_list) from (p_table)
into table <f_tab1>
up to p_row rows.
So far so good but I need to copy the data from <f_tab1> into internal table with the same structure and to use that internal table on a later stage as a driver table in select...for all entries.
How can I doo that ?
Thanks,
Stefan
<Code tags added>
Edited by: Suhas Saha on Oct 27, 2011 4:23 PM
Hello Stefan,
You might be interested in reading this thread How to use dynamic internal table with FOR ALL ENTRIES.
Do let us know if you find any alternative solution
Cheers,
Suhas
Similar Messages
-
Using where condition with dynamic internal table
Hi Friends.
How to use where condition with dynamic internal table ?
Regards,
Amit RautHai Amit
REPORT ZDYNAMIC_SELECT .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Thanks & Regards
Sreenivasulu P -
How to upload data with dynamic internal table
Hi,
I have to upload the basic , sales, purchasing view data by using bapi depend on check box selected for views.
i have filled fieldcatalog for selected views and pass the field catalog structure to dynamic int table and
import it into the field symbol <fs_data>. this field symbol assigned to <fs_1>.
then callED the 'GUI_UPLOAD ' and when i pass field symbo for function module i am getting first 10 rows 0f the file .
flat file has basic data,sales ,purchase fields data
ex: i was selected basicview and purchase view and execute i am getting basic,sales view data.
how can i get only basic and purchase data.hi ,
please find code.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fieldcatalog
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0. "#EC NEEDED
ENDIF.
So <FS_1> now points to our dynamic internal table.
ASSIGN <fs_data>->* TO <fs_1>.
Next step is to create a work area for our dynamic internal table.
CREATE DATA new_line LIKE LINE OF <fs_1>.
A field-symbol to access that work area
ASSIGN new_line->* TO <fs_2>.
ASSIGN new_line->* TO <fs_3>.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_f
filetype = 'DAT'
TABLES
data_tab = <fs_1>
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Problem with dynamic internal table updation
Hello Folks,
I created a dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = i_dyntab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN i_dyntab->* TO <f_dyntable>.
and created a work area
CREATE DATA wg_f_split LIKE LINE OF <f_dyntable>.
ASSIGN wg_f_split->* TO <f_wg_dyntable>.
My requirement is that , i have to loop a normal internal table and append those records to the filed symbol internal table.
READ TABLE i_normal_itab INTO wg_split INDEX wl_rows-index.
IF sy-subrc EQ 0.
ASSIGN wg_split to <f_wg_dyntable>.
APPEND <f_wg_dyntable> to <f_dyntable>.
endif.
here i am geeting dump as "MOVE src TO dst" ... i can get the data in the work area FSymbol but cannot append it in Internal table Field Symbol.. Please help..
<Added code tags>
Edited by: Suhas Saha on Aug 3, 2011 10:52 AMHello Sandra,
Thanks for the reply..
First i tried appending the normal work area to the fieldsymbol internal table.
append wg_split to <f_dyntable>
This is hiting dump the same dump and so i created a fieldsymbol work area. ( <f_wg_dyntable>.)and tried to append the field symbol internal table with this work area. which is again giving the dump
APPEND <f_wg_dyntable> to <f_dyntable>. ( Again a Dump)
Edited by: Charan-SAP on Aug 2, 2011 9:40 PM
Edited by: Charan-SAP on Aug 2, 2011 9:42 PM -
How to do parallel processing with dynamic internal table
Hi All,
I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
Any help will be highly appreciated.
Thanks and regards,
Ashintry the below code...
DATA: w_subrc TYPE sy-subrc.
DATA: w_infty(5) TYPE c.
data: w_string type string.
FIELD-SYMBOLS: <f1> TYPE table.
FIELD-SYMBOLS: <f1_wa> TYPE ANY.
DATA: ref_tab TYPE REF TO data.
CONCATENATE 'P' infty INTO w_infty.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
ASSIGN ref_tab->* TO <f1>.
* Create dynamic work area
CREATE DATA ref_tab TYPE (w_infty).
ASSIGN ref_tab->* TO <f1_wa>.
IF begda IS INITIAL.
begda = '18000101'.
ENDIF.
IF endda IS INITIAL.
endda = '99991231'.
ENDIF.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr
infty = infty
begda = '18000101'
endda = '99991231'
IMPORTING
subrc = w_subrc
TABLES
infty_tab = <f1>
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
subrc = w_subrc.
ELSE.
ENDIF. -
Coloring an ALV Cell with DYNAMIC INTERNAL TABLES
Hello Gurus,
I need your help regarding coloring of a cell in my ALV Grid report with DYNAMIC tables.
I have used the call method in calling my ALV. (CALL METHOD gr_alvgrid->set_table_for_first_display).
Now my problem is, I can not bring out the cellcolor succesfully, I always ended up to dump (GETWA_NOT_ASSIGNED = You attempted to access an unassigned field symbol
(data segment 32807).
What I have done:
I've created 2 internal tables:
*1st table
*After appended all of my columns to gt_fieldcat
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_both.
ASSIGN gp_both->* TO <i_xtab1>.
*2nd table
Appended these column for CellColor
CLEAR wa_gtfldcat.
wa_gtfldcat-fieldname = 'CELLCOLOR'.
wa_gtfldcat-ref_table = 'CALENDAR_TYPE'.
wa_gtfldcat-ref_field = 'COLTAB'.
APPEND wa_gtfldcat TO gt_fieldcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_alvgrid.
ASSIGN gp_alvgrid->* TO <i_xtab2>.
*Work Areas for tab1 and tab2
CREATE DATA dref1 LIKE LINE OF <i_xtab1>.
ASSIGN dref1->* TO <wa_xtab1>.
CREATE DATA dref2 LIKE LINE OF <i_xtab2>.
ASSIGN dref2->* TO <wa_xtab2>.
*Move contents of table1 to table2 and modify cellcolor column
LOOP AT <i_xtab1> ASSIGNING <wa_xtab1>.
*-----Cell color assignment
DESCRIBE TABLE gt_fieldcat.
DO sy-tfill TIMES.
READ TABLE gt_fieldcat INTO wa_gtfldcat INDEX sy-index.
ASSIGN COMPONENT wa_gtfldcat-fieldname
OF STRUCTURE <wa_xtab1> TO <fs4>.
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT wa_gtfldcat-fieldname
OF STRUCTURE <wa_xtab2> TO <fs3>.
IF sy-subrc NE 0. EXIT .ENDIF.
<fs3> = <fs4>.
ENDDO.
ASSIGN COMPONENT 'CELLCOLOR' OF STRUCTURE <wa_xtab2> TO <fs3>.
IF sy-subrc = 0.
PERFORM modify_cell_color USING 'ZZMATNR' <fs3>.
ENDIF.
APPEND <wa_xtab1> TO <i_xtab2>.
ENDLOOP.
*Call ALV
gs_layout-ctab_fname = 'COLORCELL'
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = <i_xtab2d>[]
it_fieldcatalog = gt_fieldcat
it_sort = lt_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--->Exception handling
ENDIF.
FORM modify_cell_color USING p_fieldname TYPE lvc_fname
pt_cellcolor TYPE table.
DATA l_cellcolor TYPE lvc_s_scol.
CLEAR l_cellcolor.
l_cellcolor-fname = p_fieldname.
l_cellcolor-color-col = 6. " Red.
l_cellcolor-color-int = 0.
l_cellcolor-color-inv = 0.
INSERT l_cellcolor INTO TABLE pt_cellcolor.
ENDFORM. " MODIFY_CELL_COLORHi,
The internal tabl which you are using to display the output should have one column in the end.
The cell in this column will contain an internal table of type 'lvc_s_scol'.
The contents of this internal table will be the field names of all other columns of your main internal table in the field FNAME and the required color in the field COLOR.
Please note that the field COLOR will have a hex value for different colors.
In the stucture is_layout whihc you pass to the method 'set_table_for_first_display'
the name of this last column should be given to the field 'ctab_fname'.
This will help you to give the colors to each cell.
for example
I have my data table as follows:-
ITAB1
MATNR MAKTX COLOR_TAB
1 ABC FNAME COLOR NOKEYCOL
MATNR 8000
MAKTX 8000
2 XYZ MATNR 10000
MAKTX 10000
So my internal table ITAB1 had 3 columns MATNR MAKTX and COLOR_TAB.
And COLOR_TAB will contain an internal table with 3 columns FNAME COLOR and NOKEYCOL.
The value to importing parameter IS_LAYOUT-CTAB_FNAME will be COLOR_TAB.
This will help you to assign various colors to the cell of the internal table ITAB.
When you have to change any color, then you will have to just change the entries in cell COLOR_TAB for the particular row and cell.
Regards,
Ankur Parab -
Help to work with 2 internal table with tricky use
HI ,
I have 2 internal table one with new data and one with old data (same structure ) and i want to combine the 2 of them to final table .
what i need to do here is little bit tricky
The table is build like this :
mandt
User
user_data
valid
if there is no different from the user data from table old to table new the user data in the final table should look like this
000
user1
userdata1
X
000
user1
userdata2
X
IF there is difference between of them the table entries in final table should like this
000
user1
userdata3
X
000
user1
userdata4
X
000
user1
userdata1
"Valid field is empty -abap false since the user dont have this data (userdata1) any more
000
user1
userdata2
"Valid field is empty -abap false since the user dont have this data (userdata2) any more
1. alwayes table new is coming with data that is valid field = abap_true
and should be change the user entries just if there is new entries are diffrent than the old one .
2. table new can have new users with data so it enter the new users to final table with valid entry = abap_true
3. if in the new table there is no user which exist in the old table the user in the final table
should stay with the same entries but the valid entry should be abap false
What is the best way to do that ?
Regards
Chris
Edited by: Chris Teb on Nov 15, 2009 10:39 AMHI
I have table with entries like that that i read from DB (i call it itab_old)
old_itab
mandt User user data timestemp valid
0 usr1 User_data1 X TRUE
0 usr1 User_data2 X TRUE
0 usr1 User_data3 X TRUE
0 usr2 User_data1 X TRUE
0 usr2 User_data2 X TRUE
0 usr2 User_data3 X TRUE
0 usr2 User_data4 X TRUE
0 usr3 User_data1 X TRUE
0 usr3 User_data2 X TRUE
0 usr3 User_data3 X TRUE
assume the user entry for usr 1 is changing i.e. (new entries in table itab_new) the table should look like this
new_itab
mandt User user data timestemp valid
0 usr1 User_data4 Y TRUE
0 usr1 User_data2 Y TRUE
0 usr1 User_data6 Y TRUE
0 usr2 User_data1 Y TRUE
0 usr2 User_data2 Y TRUE
0 usr2 User_data3 Y TRUE
0 usr2 User_data4 Y TRUE
and the final_itab should look like that
usr1 old entries are mark as false and new recoreds is enter to the table for him ,
usr2 have the same entries so it not change
final_itab
mandt User user data timestemp valid
0 usr1 User_data1 X FALSE
0 usr1 User_data2 X FALSE
0 usr1 User_data3 X FALSE
0 usr2 User_data1 X TRUE
0 usr2 User_data2 X TRUE
0 usr2 User_data3 X TRUE
0 usr2 User_data4 X TRUE
0 usr3 User_data1 X TRUE
0 usr3 User_data2 X TRUE
0 usr3 User_data3 X TRUE
0 usr1 User_data4 Y TRUE
0 usr1 User_data2 Y TRUE
0 usr1 User_data6 Y TRUE
0 usr7 User_data1 X TRUE
0 usr7 User_data2 X TRUE
0 usr7 User_data3 X TRUE
last thing there is option that new user will come in table new_itab that is not exist in old table for this user we need to create new entry in final table (like user 7 )
Thanks in advance
Chris
Edited by: Chris Teb on Nov 15, 2009 10:50 PM -
How to write a perform with dynamic internal table
Hi to all experts,
i have to read infotype 2001 2003 2002 with same pernr, begin date, end date im calling hr_read_infotype three times
can i write a single perform and call it three how to pass different tables (2001, 2002, 2003).try the below code...
DATA: w_subrc TYPE sy-subrc.
DATA: w_infty(5) TYPE c.
data: w_string type string.
FIELD-SYMBOLS: <f1> TYPE table.
FIELD-SYMBOLS: <f1_wa> TYPE ANY.
DATA: ref_tab TYPE REF TO data.
CONCATENATE 'P' infty INTO w_infty.
CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
ASSIGN ref_tab->* TO <f1>.
* Create dynamic work area
CREATE DATA ref_tab TYPE (w_infty).
ASSIGN ref_tab->* TO <f1_wa>.
IF begda IS INITIAL.
begda = '18000101'.
ENDIF.
IF endda IS INITIAL.
endda = '99991231'.
ENDIF.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr
infty = infty
begda = '18000101'
endda = '99991231'
IMPORTING
subrc = w_subrc
TABLES
infty_tab = <f1>
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
subrc = w_subrc.
ELSE.
ENDIF. -
hi all,
i am working with dynamic internal table. how to use a read statement for the dynamic internal table.
Thankshi
try with this sample code.
DATA: tab TYPE TABLE OF mara,
field_key TYPE char100.
FIELD-SYMBOLS: <tab> TYPE ANY TABLE,
<wa> TYPE ANY.
SELECT * UP TO 10 ROWS FROM mara INTO TABLE tab[].
ASSIGN tab[] TO <tab>.
field_key = 'MATNR'.
READ TABLE <tab> ASSIGNING <wa>
WITH KEY (field_key) = '000000000000000200'.
Cheers,
Madhu -
How to delete records from dynamic internal table.
Hi Experts,
Need urgent help!!!
Issue is with Dynamic internal tables.
Below is code written by me :
FORM select_query USING Lw_tabnam
TYPE t682i-kotabnr.
DATA : lw_line TYPE REF TO data,
lw_line1 TYPE REF TO data.
CREATE DATA Lw_line TYPE (lw_TABNAM).
ASSIGN Lw_line->* TO <WA_tbl>.
CREATE DATA LW_LINE TYPE STANDARD TABLE OF (Lw_tabnam)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN Lw_line->* TO <TBL>.
SELECT * FROM (Lw_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <TBL>
WHERE (t_keys).
Endform.
code is working fine.
here even the table name and where condition are dynamic,everything is fine upto this point.
Now i have to delete some record from <TBL> based on some conditons.
for ex : ( here lc_fieldname is KUNNR)
loop at t_kunnr.
lw_tabix = sy-tabix.
Read table <tbl>
with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
If sy-subrc = 0.
*Delete
delete <tbl> from <wa_tbl>
delete <tbl> index lw_tabix.
Endif.
Endloop.
The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
Can you help me ab't how to delete records in Dynamic internal table?
Other option that i am thinking of is to create a static table of type dynamic table.
means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
Thanks in advance ,
If you have any suggestion ab't this then do let me know.
bye,
Gaurav.Hi
I wrote this code and it works fine:
DATA LW_TABNAM(10) VALUE 'LFA1'.
DATA : LW_LINES TYPE REF TO DATA,
LW_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <TABLE> TYPE TABLE,
<WA> TYPE ANY.
CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN LW_LINES->* TO <TABLE>.
CREATE DATA LW_LINE TYPE (LW_TABNAM).
ASSIGN LW_LINE->* TO <WA>.
DO 10 TIMES.
APPEND INITIAL LINE TO <TABLE>.
ENDDO.
SY-TABIX = 4.
DELETE <TABLE> INDEX SY-TABIX.
WRITE SY-SUBRC.
I hope it help you
Max -
Dynamic internal table operations
Hi,
I have an issue with dynamic internal table wherein I need to write a select statement with For All Entries on dynamic internal table and populating the record into another dynamic internal table.
I am trying with the code below but its not working.
SELECT (FLD)
FROM (T_TABLE)
INTO CORRESPONDING FIELDS OF TABLE <DYN1_TABL>
FOR ALL ENTRIES IN <DYN_TABL>
WHERE KEY_FNAME = <DYN_TABL>-KEY_FNAME.
FLD is the dynamic field.
T_TABLE is the dynamic database table.
DYN1_TABL is the dynamic internal table
DYN_TABL is the dynamic internal table
KEY_FNAME is the dynamic key field of T_TABLE.
Pls help me on this issue.
Response with code snippets will be appreciated.
Thanks in advance.Thanks for your reply Nikki but my issue is to reference a field in dynamic internal table to be used with 'For All Entries' satement.
like for static we use
For All Entries in Itab where <fieldname> = itab-<fieldname>
I was looking for the same statement for dynamic tables -
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. -
Hi all,
I have created 2 tabstrip screns which contain ALV GRID DISPLAY in a container with dynamic internal table and editable columns .I want to capture the edited value from this ALV GRID display.I have used SET_TABLE_FOR_DISPLAY and for this dynamc internal table is passed which is Field symbol and editable columns have to be captured for further updation into another ztable.
When i used check_changed_data i am getting dump as field symbol not assigned.
Below is the code : How can i get edited column value from below code
call method alv_list->set_table_for_first_display
exporting
is_layout = gs_layout
changing
it_outtab = <fs_dynamic_table>
it_fieldcatalog = it_fieldcat[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
Kindly help me to solve this.
With Thanks,
Dina.please provide more info about the dump to try to help you
as max said, it could be because the field symbol is not global and if its global maybe you are not refering well to the column
i assume that you are using "ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>" to capture the value changed
validate always the sy-subrc after the assignment.
but the check changed data have parameters that have the old and new values
please provide more info...
Regards -
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 -
Dynamic internal table column issue
Hi
i have ALV report with dynamic internal table.after i build the internal table and fieldcatalog i have problem i.e. when grid is displayed then one of the column value is coming in the next column.i populated col_pos in field catalog also and in the debug mode data is populated correctly for respective columns in fieldcatalog and dynamic internal table. But when it is displayed i have this problem.
any inputs on this?Hi Moorthy,
Did you perform an ALV consistency check?
Check the below given links as well.
The Consistency Check - ALV Grid Control (BC-SRV-ALV) - SAP Library
SAP ALV Consistency Check
Regards,
Philip.
Maybe you are looking for
-
I want to upgrade my ( iMAC 800Mhz Power PC G4 & iBOOK 700Mhz PC G3)
Hello! I want to upgrade if possible over 1GB ? my now slow computer ( iMAC 800Mhz Power PC G4 ) and a ( iBOOK 700Mhz Power PC G3 ) which I don't think I'm confident enough to change the internal memory but the user memory I think I can attempt! So I
-
Downloaded itunes 10.5 dmg open it after download chesum error shows when skipping de cheskum check and installing itunes it won't install! in console the description beneath shows. Can some one please help me? 12-10-11 23:27:33,449 installd: Package
-
Error in file cc attemp to process file due java.lang.NullPointerException
there is an error in file communication channel with error information *Delivery of the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: java.lang.NullPointerE
-
Help needed: navigation menu doesn't display on Explorer but does on Safari
Can someone help. I have a site that has a navigation menu at the top and when I publish to a folder or view on my mac the pages and navigation works correctly. When I view with explorer, the navigation menu doesn't display correctly (at all) and I g
-
Gap between divs, but only in IE6
I created a page at http://www.gruenconstruction.com/gallerycontemporary.htm with a top, middle and bottom div (mainly). For some reason, in IE6 there's a huge gap between the middle and bottom divs. It looks perfect in Opera, IE 7 and FF. I can't fi