Urgent problem: grouping by fields of internal table
Hi friend,
i have a urgent problem and i hope that you can help me out:
i have an internal table containing data, and i sorted it by 3 fields.
now what i want to do is kind of grouping that means that all the lines that are the same should be written into another internal table like this:
A
A
B
B
B
C
D
would give me:
A 1
A 1
B 2
B 2
B 2
C 3
D 4
How could i do this ( especially avoiding nested loops ? ) Is there a handy trick to do this efficiently ?
thank you, i will give points immediately,
Clemens
Hello,
The field position is important for the fields that are using in the control break statements..Also SORT internal table is required.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
VALUE TYPE NETPR,
END OF ITAB.
ITAB-MATNR = 'ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
ITAB-MATNR = '1ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
SORT ITAB BY MATNR WERKS.
LOOP AT ITAB.
AT FIRST.
WRITE : 'AT FIRST'.
ENDAT.
AT NEW MATNR.
WRITE : 'AT NEW MATERIAL NUMBER'.
ENDAT.
AT END OF MATNR.
SUM.
WRITE: / ITAB-MATNR, 'MATERIAL TOTAL - ', ITAB-VALUE.
ENDAT.
AT END OF WERKS.
SUM.
WRITE: / ITAB-WERKS, 'PLANT TOTAL - ', ITAB-VALUE.
ENDAT.
AT LAST.
WRITE : 'AT LAST'.
ENDAT.
ENDLOOP.
Regards,
Deepu.K
Similar Messages
-
How to handle field symbols internal table values?
HI all,
I declared field string as below.The below code is working fine.
Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
wa_itab like line of ITAB.
field-symbol : <fs> type ITAB.
ASSIGN PARAM TO <FS>
LOOP AT <FS> INTO WA_ITAB.
WRITE:/ 'ABC'.
ENDLOOP.
But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
Data : BEGIN OF ITAB1 OCCURS 0,
FIELD1 LIKE YAPOPLN-FIELD1,
FIELD2 LIKE YAPOPLN-FIELD2,
END OF ITAB1.
field-symbol : <fs> LIKE ITAB1 OR <FS> TYPE ANY.
DATA :WA_ITAB1 LIKE LINE OF ITAB1.
ASSIGN PARAM TO <FS>
LOOP AT <FS> INTO WA_ITAB.
WRITE:/ 'ABC'.
ENDLOOP.
But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
.'FS' is not an internal table or defined in TABLES.
Can anyone help me in this regard?
Thanks,
BalajiHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM -
How to move field symbol internal table to internal table with header line?
Dear all,
hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
as i know field symbol internal table is without header line..
so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
Please advise...
Thanks
Regard,
ToToRo.
Edited by: @ToToRo@ on Aug 20, 2009 6:16 AMHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM -
How To select maximum Value in a specifieid field in internal table.
How To select maximum Value in a specifieid field in internal table?
Step : 1
Sort itab by <Field1> descending.
Just sort the internal table by the field.
STEP: 2
Then read the table at index 1.
Read table itab index 1.
ITAB-FIELD = MAX . " Max field will come in the first row of the internal table.
Regards,
Gurpreet -
Assign function code to a field in internal table
Hi all,
Can we assign a function code to one field in internal table so that we can use it as an user command in list display.
For ex:
data : begin of itab occurs 0,
check(1) type C,
num type I,
end of itab.
I am preparing a list display using WRITE statements.
I'ld like to update the checked value of check box as soon as the user selects a check box. So I would like to assign a function code to this check box. Then I can use AT user-command.Hi,
dinesh's apporach is not bad, but
1. the structure' name cannot be part of the component
2. you need to make sure the component-name always is in upper case.
Try adapting the following code:
data: begin of wa_test,
field01 type string,
field02 type string,
field03 type string,
end of wa_test.
data: l_fieldname type string,
l_counter type string.
field-symbols: <testc> type string.
do 3 times.
l_counter = sy-index.
concatenate 'field0' l_counter into l_fieldname.
translate l_fieldname to upper case.
assign component l_fieldname of structure wa_test to <testc>.
if <testc> is assigned.
<testc> = 'any value'.
endif.
enddo.
write / wa_test-field01.
best regards -
How to add the contents of a field of internal table.
Hello Everybody,
How to sum up the individual field from a internal table. Like i have a internal table that has menge field , I need to sum up the menge field for each matnr..
exm : for each matnr there are 5 menge entries, I need to add all the menge fields and shud be put against the matnr .
Thanks,Hi Khaleel,
One more option is using the "collect" statement.....
imagine in the internal table itab..we have 2 fields only..
MATNR,MENGE,
we have 2 internal tables itab1 and itab2...
loop at itab1.
collect itab1 to itab2.
endloop.
Action performed is ...for the same MATNR...menge gets added and saved as a single record...When matnr changes...new record is Appended
another case is we have 3 fields in internal table
MATNR,UNIT,MENGE
imagine we hane the records
Material1 KG 100
Material1 LT 20
Material1 LT 200
MAterial2 KG 100
in this case...the output will be
Material1 KG 100
Material1 LT 220
MAterial2 KG 100
Reason is that the fields before the addable value is checked for similarity..
here field UNIT is also checked and also MATNR before adding up....
Hope it gave you some alternative idea to proceed with....
Reward if helpful
Regards
Byju -
Read contents of changing fields from internal table
Hi Folks,
Please help me in my query below:
Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
So how can I read the particular field from internal table as the field to be read is dynamic.
Note: using case is not feasible.
Thanks in advance.
Regards,
Shardul@Hartmut P
As Rob said i want to get the value of the field from internal table. the code is something like this.
I_KNA1 contains records for customers.
Suppose values of Z-table are in internal table I_TEMP_TABLE.
Entries in I_TEMP_TABLE are as follows
TABNAME FIELDNAME
KNA1 NAME1
The value of FIELNAME in Z-table can be changed
Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
IF SY-SUBRC EQ 0.
CASE WA_TEMP_TABLE-FIELDNAME.
WHEN 'NAME1'.
V_VAR = WA_KNA1-NAME1.
WHEN 'PSTLZ'
V_VAR = WA_KNA1-PSTLZ.
ENDIF.
But using case is not appropriate as KNA1 contains 176 fields. -
Problem with creating an dynamic internal table with only one field.
Hi,
i create an internal table like this:
FIELD-SYMBOLS: <GT_ITAB> TYPE TABLE,
<GS_ITAB>,
<FS>.
DATA: GT_DATA TYPE REF TO DATA.
DATA: GS_DATA TYPE REF TO DATA.
DATA: TABNAME LIKE DD03L-TABNAME.
DATA: FIELDNAME LIKE DD03L-FIELDNAME.
DATA: TBFDNAM TYPE TBFDNAM VALUE 'LFA1-NAME1'.
SPLIT TBFDNAM AT '-' INTO TABNAME FIELDNAME.
CREATE DATA GT_DATA TYPE TABLE OF (TABNAME).
ASSIGN GT_DATA->* TO <GT_ITAB>.
CREATE DATA GS_DATA LIKE LINE OF <GT_ITAB>.
ASSIGN GS_DATA->* TO <GS_ITAB>.
SELECT * FROM (TABNAME) INTO CORRESPONDING FIELDS OF TABLE <GT_ITAB>.
BREAK-POINT.
it works OK.
Now i want to create an internal table not like LFA1 but with LFA1-NAME1 Field TBFDNAM.
It's not only LFA1-NAME1 it shell be the value of TBFDNAM.
When i change
CREATE DATA GT_DATA TYPE TABLE OF (TABNAME).
to
CREATE DATA GT_DATA TYPE TABLE OF ( TBFDNAM).
i get an shortdump.
Any idea?
Regards, DieterHi Dieter,
Your approach is ok, but it will create dynamic table without a structure of NAME1. Only the line type will be suitable (but field name will not exists -> hence the error in the select statement).
In this case you need to create a dynamic table which structure consists of one field named NAME1.
This code is the appropriate one:
" your definitions
DATA: tabname LIKE dd03l-tabname.
DATA: fieldname LIKE dd03l-fieldname.
DATA: tbfdnam TYPE tbfdnam VALUE 'LFA1-NAME1'.
FIELD-SYMBOLS <gt_itab> TYPE table.
"new ones
DATA: it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
DATA: gt_itab TYPE REF TO data.
" get table and fieldname
SPLIT tbfdnam AT '-' INTO tabname fieldname.
" create dynamic table with structure NAME1 (only one field)
it_fcat-fieldname = fieldname.
it_fcat-tabname = tabname.
APPEND it_fcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat[]
IMPORTING
ep_table = gt_itab
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
CHECK sy-subrc = 0.
" dereference table
ASSIGN gt_itab->* TO <gt_itab>.
" insert data only to NAME1 field
SELECT * FROM (tabname) INTO CORRESPONDING FIELDS OF TABLE <gt_itab>.
I checked, this works fine:)
Regards
Marcin -
Really urgent: reagrding alv format for like (internal tables)
Hi,
I making a report in which i am using the concept of 2 internal tables and i am usnig the concept of likes in a internal table .
for instance,
DATA : BEGIN OF ITAB OCCURS 0,
ITEMID LIKE CHVW-MATNR,
WERKS LIKE CHVW-WERKS,
CHARG LIKE CHVW-CHARG,
SHKZG LIKE CHVW-SHKZG,
MENGE LIKE CHVW-MENGE,
MEINS LIKE CHVW-MEINS,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
MATNR TYPE BSEG-MATNR,
LIFNR TYPE BSEG-LIFNR,
AUGDT TYPE BSEG-AUGDT,
WRBTR TYPE BSEG-WRBTR,
END OF IT_BSEG.
and i am able to create ALV for 1 itab only as i had declared all fields in a 1 itab ,but now i have to declare 1 more itab and i dont know how to perform ALV with 2 itabs..
Plzz help me out as it is really urgent to me.
Edited by: ric .s on Apr 22, 2008 11:45 AM
Edited by: ric .s on Apr 23, 2008 7:21 AM
Edited by: ric .s on Apr 23, 2008 7:55 AMHi Ric,
Yes, You can .
Check the sample ALV program which helps u in displaying output using ALV . Comments have been made everywhere .
report zvenkat_alv_2_grid_description.
types:
begin of t_mard,
werks type mard-werks,
lgort type mard-lgort,
matnr type mard-matnr,
insme type mard-insme,
einme type mard-einme,
speme type mard-speme,
end of t_mard.
data:
w_mard type t_mard.
data:
i_mard type standard table of t_mard.
" ALV Declarations
" ALV internal tables and Structures
" To refer ALV tables(slis tables) and structures.SLIS must be
" declared under TYPE-POOLS(see below).SLIS is a Type group which is
" defined in Dictionary.Internal tables and structures and constants
" are defined under type group.(Double click on SLIS).
* Types Pools
type-pools:
slis.
* Types
types:
t_fieldcat type slis_fieldcat_alv,
t_events type slis_alv_event,
t_layout type slis_layout_alv.
* Workareas
data:
w_fieldcat type t_fieldcat,
w_events type t_events,
w_layout type t_layout.
* Internal Tables
data:
i_fieldcat type standard table of t_fieldcat,
i_fieldcat1 type standard table of t_fieldcat,
i_events type standard table of t_events.
*& START-OF-SELECTION
start-of-selection.
perform get_data_from_database .
" END-OF-SELECTION
" Steps to create simple ALV program
" 1. Pass an internal table with the set of output information
" 2. Pass a field catalog as an internal table
" 3. Pass a structure with general list layout details
end-of-selection.
perform build_fieldcatalog.
perform build_events.
perform build_layout.
perform display_data.
" Form build_fieldcatalog
" Fieldcatalog Internal table
" 1. It contains descriptions of the list output fields
" (usually a subset of the internal output table fields).
" 2. A field catalog is required for every ALV list output.
form build_fieldcatalog .
clear :
w_fieldcat,
i_fieldcat[].
perform build_fcat using:
"Field Int.Table Column headings
'WERKS' 'I_MARD' 'WERKS',
'LGORT' 'I_MARD' 'LGORT',
'MATNR' 'I_MARD' 'MATNR',
'INSME' 'I_MARD' 'INSME',
'EINME' 'I_MARD' 'EINME',
'SPEME' 'I_MARD' 'SPEME'.
endform. " build_fieldcatalog
*& Form display_data
form display_data .
data :program like sy-repid value sy-repid.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
tables
t_outtab = i_mard.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " display_data
*& Form get_data_from_database
* text
form get_data_from_database .
clear :i_mard,
i_mard[].
select werks lgort matnr insme einme speme
from mard
into corresponding fields of table i_mard
up to 100 rows.
endform. " get_data_from_database
*& Form top_of_page
* text
form top_of_page.
data :
i_header type slis_t_listheader,
w_header like line of i_header.
data:l_date1 type datum,
l_date2 type datum.
w_header-typ = 'S'.
w_header-info = sy-title.
append w_header to i_header.
clear w_header.
w_header-typ = 'H'.
w_header-info = sy-repid.
append w_header to i_header.
clear w_header.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_header
i_logo = 'ENJOYSAP_LOGO'.
endform. "top_of_page
*& Form BUILD_FCAT
form build_fcat using l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
append w_fieldcat to i_fieldcat.
clear w_fieldcat.
endform. " BUILD_FCAT
" Form build_events
" Events
" 1. When we use ALV,certain events TOP-OF-PAGE ,END-OF-PAGE,
" AT LINE-SELECTION,AT USER-COMMANDs are not triggered.
" 2. To perform those Functions ,we have to build Events table and
" pass this table through REUSE_ALV_LIST_DISPALY Function.
form build_events .
clear :
w_events,i_events[].
w_events-name = 'TOP_OF_PAGE'.
w_events-form = 'TOP_OF_PAGE'.
append w_events to i_events.
clear w_events.
endform. " build_events
"& Form build_layout
" Layouts
" Use :We change the display of our list using layouts.
" ===
" Features
" ========
" The layouts that you can use vary according to the type of list:
" 1-->In all lists, you can do the following:
" (a).Choose one of the std layouts supplied with the std system.
" (b).Change the current layout of the list .
" 2-->In lists that use only the standard layouts in the std system
" you cannot save your changes to the current layout.When you
" choose the layouts, only the standard layouts will be proposed.
" 3-->In some lists, you can also save the layouts that you have
" defined as our own layouts.
" User-defined layouts are generally saved for all users. They can
" then be used by all users. All users will be able to choose from
" the user-defined layouts as well as the standard layouts.
" 4-->In some lists, you can also save user-specific layouts that you
" have defined . When you choose the current layout,only these
" layouts are available to you.
" 5-->You can delete or transport layouts, or define them as initial
" layouts
" 6-->STRUCTURE :SLIS_LAYOUT_ALV.
form build_layout .
clear:
w_layout.
w_layout-colwidth_optimize = 'X'.
endform. " build_layout
Regards,
Venkat.O -
Field catalog & internal table are not mutually convertible
Hi friends,
please help me for this problem, actually i m trying to display three alv reports from the three buttond i have given on my first basic report. its working fine till first & getting the data into the internal table for the second also. but when coming to the field catalog for the second report its giving syntax error as my "field catalog and internal table are not mutually convertible'".i have tried by giving different fieldcatalog also but its giving the same problem.please help for this & try to give an example if u can. Thanks a lot.
Regards
PankajThis is my code :
TABLES: PLAF,
MARA,
MAKT,
AFPO,
T023T,
VSAUFK,
T006A,
MBEW,
ZCDR_D.
Type Pools for ALV *************************
TYPE-POOLS: SLIS,
ABAP.
KKBLO.
DATA DECLARATION. ****************************
DATA: FLAG TYPE I,
FLAG1 TYPE I,
FLAG2 TYPE I,
FLAG3 TYPE I,
FLAG4 TYPE I,
FLAG5 TYPE I.
********Declaration for field catalog
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LAYOUT1 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV,
LAYOUT2 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT2 TYPE SLIS_FIELDCAT_ALV,
LAYOUT3 TYPE SLIS_LAYOUT_ALV,
IT_FIELDCAT3 TYPE SLIS_T_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
WA_SUBT LIKE SLIS_EV_SUBTOTAL_TEXT,
IT_EVENTS TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
WA_FIELDCAT3 TYPE SLIS_FIELDCAT_ALV.
TYPES DECLARATION. ****************************
TYPES: BEGIN OF TY_MARA,
MATNR LIKE MARA-MATNR, " Material Number
MATKL LIKE MARA-MATKL, " Material Group
END OF TY_MARA.
TYPES: BEGIN OF TY_PLAF,
PERTR LIKE PLAF-PERTR, " Date
PLNUM LIKE PLAF-PLNUM, " Planned Order Number
MATNR LIKE PLAF-MATNR, " Material number
PLWRK LIKE PLAF-PLWRK, " Plant
KDAUF LIKE PLAF-KDAUF, " Sales Order Number
KDPOS LIKE PLAF-KDPOS, " SO Line Item
END OF TY_PLAF.
TYPES: BEGIN OF TY_MAKT,
MATNR LIKE PLAF-MATNR, " Material Number
MAKTX LIKE MAKT-MAKTX, " Material Description
END OF TY_MAKT.
TYPES: BEGIN OF TY_AFPO,
PLNUM LIKE AFPO-PLNUM, " Planned Order Number
MATNR LIKE AFPO-MATNR, " Material Number
KDAUF LIKE AFPO-KDAUF, " Sales Order Number
KDPOS LIKE AFPO-KDPOS, " SO Line Item
AUFNR LIKE AFPO-AUFNR, " Production Order
STRMP LIKE AFPO-STRMP,
DWERK LIKE AFPO-DWERK,
END OF TY_AFPO.
TYPES: BEGIN OF TY_ZCDR_D,
MANDT LIKE ZCDR_D-MANDT, " Client
CBNO LIKE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE ZCDR_D-PLNUM, " Planned Order Number
MATNR LIKE ZCDR_D-MATNR, " Material Number
MAKTX LIKE ZCDR_D-MAKTX, " Material Description
KDAUF like ZCDR_D-KDAUF, " Sales Order Number
KDPOS like ZCDR_D-KDPOS, " SO Line Item
AUFNR LIKE ZCDR_D-AUFNR, " Production Order
END OF TY_ZCDR_D.
TYPES: BEGIN OF TY_VSAUFK,
INACT LIKE VSAUFK-INACT, " Status Indicator
END OF TY_VSAUFK.
TYPES: BEGIN OF TY_PLAF_MAKT,
CBNO LIKE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE PLAF-PLNUM, " Planned Order Number
CHK TYPE C, " Check Box
MATNR LIKE PLAF-MATNR, " Material Number
MAKTX LIKE MAKT-MAKTX, " Material Description
KDAUF LIKE PLAF-KDAUF, " Sales Order Number
KDPOS LIKE PLAF-KDPOS, " SO Line Item
AUFNR LIKE AFPO-AUFNR, " Production Order
END OF TY_PLAF_MAKT.
TYPES: BEGIN OF TY_HELP_ITEM,
CBNO TYPE ZCDR_D-CBNO, " Customs Book Number
PLNUM LIKE ZCDR_D-PLNUM, " Planned Order Number
MATNR LIKE ZCDR_D-MATNR, " Material Number
MAKTX LIKE ZCDR_D-MAKTX, " Material Description
KDAUF LIKE ZCDR_D-KDAUF, " Sales Order Number
KDPOS LIKE ZCDR_D-KDPOS, " SO Line Item
AUFNR LIKE ZCDR_D-AUFNR, " Production Order
END OF TY_HELP_ITEM.
WORK AREA ******************************
DATA: WA_MARA TYPE TY_MARA,
WA_PLAF TYPE TY_PLAF,
WA_MAKT TYPE TY_MAKT,
WA_AFPO TYPE TY_AFPO,
WA_ZCDR_D TYPE TY_ZCDR_D,
WA_VSAUFK TYPE TY_VSAUFK,
WA_PLAF_MAKT TYPE TY_PLAF_MAKT,
WA_HELP_ITEM TYPE TY_HELP_ITEM.
INTERNAL TABLES ****************************
DATA: IT_MARA TYPE TABLE OF TY_MARA,
IT_PLAF TYPE TABLE OF TY_PLAF,
IT_MAKT TYPE TABLE OF TY_MAKT,
IT_AFPO TYPE TABLE OF TY_AFPO,
IT_ZCDR_D TYPE TABLE OF TY_ZCDR_D,
IT_VSAUFK TYPE TABLE OF TY_VSAUFK,
IT_PLAF_MAKT TYPE TABLE OF TY_PLAF_MAKT,
IT_HELP_ITEM TYPE TABLE OF TY_HELP_ITEM.
*it_events TYPE TABLE OF slis_alv_event WITH NON-UNIQUE DEFAULT KEY
*WITH HEADER LINE INITIAL SIZE 0.
TYPES: BEGIN OF TY_BOM,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
VPRSV LIKE STPOX-VPRSV,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_BOM,
BEGIN OF TY_QUAN,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_QUAN,
BEGIN OF TY_T023T,
MATKL LIKE T023T-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF TY_T023T,
BEGIN OF TY_T006A,
MMEIN LIKE T006A-MSEHI,
MSEHT LIKE T006A-MSEHT,
END OF TY_T006A,
BEGIN OF TY_IMP_FINAL,
SNO TYPE SY-INDEX,
HSCODE LIKE ZHSCODE-HSCODE,
WGBEZ TYPE T023T-WGBEZ,
SPEC(20) TYPE C,
MNGLG LIKE STPOX-MNGLG,
MSEHT LIKE T006A-MSEHT,
CNTRY(13) TYPE C,
UPRICE TYPE P LENGTH 16 DECIMALS 2,
TPRICE TYPE P LENGTH 16 DECIMALS 2,
CURRCODE TYPE C LENGTH 5,
END OF TY_IMP_FINAL,
BEGIN OF TY_MBEW,
MATNR LIKE MBEW-MATNR,
VPRSV LIKE MBEW-VPRSV,
STPRS LIKE MBEW-STPRS,
VERPR LIKE MBEW-VERPR,
END OF TY_MBEW.
DATA: WA_BOM TYPE TY_BOM,
WA_QUAN TYPE TY_QUAN,
WA_IMP_FINAL TYPE TY_IMP_FINAL,
WA_T023T TYPE TY_T023T,
WA_T006A TYPE TY_T006A,
WA_MBEW TYPE TY_MBEW.
DATA: IT_BOM TYPE TABLE OF TY_BOM,
IT_QUAN TYPE TABLE OF TY_QUAN,
IT_IMP_FINAL TYPE TABLE OF TY_IMP_FINAL,
IT_MBEW TYPE TABLE OF TY_MBEW.
SELECTION-SCREEN **************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS : PR_CBNO LIKE ZCDR_D-CBNO OBLIGATORY. "Customs Book number
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION **************************
INITIALIZATION.
**PERFORM CLEAR_DATA.
**CLEAR: wa_layout.
*PERFORM set_events USING it_events[].
SELECT OPTION ****************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS:
SO_PERTR for PLAF-PERTR, "----
Date
SO_MATNR for MARA-MATNR, "----
Material
SO_MATKL for MARA-MATKL, "----
Material Group
SO_PLWRK for PLAF-PLWRK OBLIGATORY, "----
Plant
SO_KDAUF for PLAF-KDAUF. "----
Sales Order
SELECTION-SCREEN : END OF BLOCK BLK.
SELECTION SCREEN F4 HELP *********************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PR_CBNO.
DATA: DYNFIELDS TYPE TABLE OF DYNPREAD WITH HEADER LINE.
DYNFIELDS-FIELDNAME = PR_CBNO.
APPEND DYNFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TRANSLATE_TO_UPPER = 'X'
REQUEST = ' '
PERFORM_CONVERSION_EXITS = ' '
PERFORM_INPUT_CONVERSION = ' '
DETERMINE_LOOP_INDEX = ' '
START_SEARCH_IN_CURRENT_SCREEN = ' '
START_SEARCH_IN_MAIN_SCREEN = ' '
START_SEARCH_IN_STACKED_SCREEN = ' '
START_SEARCH_ON_SCR_STACKPOS = ' '
SEARCH_OWN_SUBSCREENS_FIRST = ' '
SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
DYNPFIELDS = DYNFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 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.
READ TABLE DYNFIELDS WITH KEY FIELDNAME = 'CBNO'.
PR_CBNO = DYNFIELDS-FIELDVALUE.
SELECT
CBNO
PLNUM
MATNR
MAKTX
KDAUF
KDPOS
AUFNR
FROM ZCDR_D
INTO TABLE IT_HELP_ITEM .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'CBNO'
PVALKEY = ' '
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'PR_CBNO'
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = IT_HELP_ITEM
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
***********************SELECTION SCREEN VALIDATION.*******************
AT SELECTION-SCREEN ON PR_CBNO.
SELECT SINGLE *
FROM ZCDR_D
WHERE CBNO = PR_CBNO.
IF SY-SUBRC EQ 0.
MESSAGE E000(ZCBR) WITH PR_CBNO.
ENDIF.
AT SELECTION-SCREEN ON SO_PERTR.
IF SO_PERTR IS NOT INITIAL.
SELECT SINGLE *
FROM PLAF
WHERE PERTR IN SO_PERTR.
IF SY-SUBRC NE 0.
MESSAGE W001(ZCBR) WITH SO_PERTR-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_MATNR.
IF SO_MATNR IS NOT INITIAL.
SELECT SINGLE *
FROM MARA
WHERE MATNR IN SO_MATNR.
IF SY-SUBRC NE 0.
MESSAGE W002(ZCBR) WITH SO_MATNR-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_MATKL.
IF SO_MATKL IS NOT INITIAL.
SELECT SINGLE *
FROM MARA
WHERE MATKL IN SO_MATKL.
IF SY-SUBRC NE 0.
MESSAGE W003(ZCBR) WITH SO_MATKL-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_PLWRK.
IF SO_PLWRK IS NOT INITIAL.
SELECT SINGLE * FROM PLAF
WHERE PLWRK IN SO_PLWRK.
IF SY-SUBRC NE 0.
MESSAGE W004(ZCBR) WITH SO_PLWRK-LOW.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON SO_KDAUF.
IF SO_KDAUF IS NOT INITIAL.
SELECT SINGLE * FROM PLAF
WHERE KDAUF IN SO_KDAUF.
IF SY-SUBRC NE 0.
MESSAGE W005(ZCBR) WITH SO_KDAUF-LOW.
ENDIF.
ENDIF.
*********************START-OF-SELECTION.*****************************
START-OF-SELECTION.
IF so_pertr IS NOT INITIAL.
FLAG = 1.
ENDIF.
IF SO_MATNR IS NOT INITIAL.
FLAG1 = 1.
ENDIF.
IF so_matkl IS NOT INITIAL.
FLAG2 = 1.
ENDIF.
IF so_plwrk IS NOT INITIAL.
FLAG3 = 1.
ENDIF.
IF so_kdauf IS NOT INITIAL.
FLAG4 = 1.
ENDIF.
Select data into its internal table from different database tables
SELECT
MATNR
MATKL
MTART
INTO CORRESPONDING FIELDS OF TABLE IT_MARA
FROM MARA
WHERE MTART = 'ZFGS'.
IF FLAG2 NE 0.
DELETE IT_MARA WHERE
NOT ( MATKL IN SO_MATKL )
ENDIF.
IF FLAG1 NE 0.
DELETE IT_MARA WHERE
NOT ( MATNR IN SO_MATNR )
ENDIF.
SELECT
PERTR
PLNUM
MATNR
PLWRK
KDAUF
KDPOS
FROM PLAF
INTO CORRESPONDING FIELDS OF TABLE IT_PLAF
FOR ALL ENTRIES IN IT_MARA
WHERE PLWRK IN SO_PLWRK
AND MATNR = IT_MARA-MATNR.
SELECT
MATNR
PLNUM
AUFNR
KDAUF
KDPOS
STRMP
DWERK
INACT
FROM AFPO
INTO CORRESPONDING FIELDS OF TABLE IT_AFPO
FOR ALL ENTRIES IN IT_MARA
WHERE DWERK IN SO_PLWRK
AND MATNR = IT_MARA-MATNR.
WHERE MATNR = IT_MARA-MATNR
AND STRMP = IT_PLAF-PERTR
AND KDAUF = IT_PLAF-KDAUF
AND DWERK = IT_PLAF-PLWRK.
End of Data selection
Keep only those records which the user wants from his selection screen
IF FLAG NE 0.
DELETE IT_PLAF WHERE
NOT ( PERTR IN SO_PERTR )
DELETE IT_AFPO WHERE
NOT ( STRMP IN SO_PERTR )
ENDIF.
IF FLAG3 NE 0.
DELETE IT_PLAF WHERE
NOT ( PLWRK IN SO_PLWRK )
DELETE IT_AFPO WHERE
NOT ( DWERK IN SO_PLWRK )
ENDIF.
IF FLAG4 NE 0.
DELETE IT_PLAF WHERE
NOT ( KDAUF IN SO_KDAUF )
DELETE IT_AFPO WHERE
NOT ( KDAUF IN SO_KDAUF )
ENDIF.
SELECT
MATNR
MAKTX
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE IT_MAKT
FOR ALL ENTRIES IN IT_PLAF
WHERE MATNR = IT_PLAF-MATNR
AND SPRAS = 'EN'.
SELECT
FROM ZCDR_D
INTO TABLE IT_ZCDR_D.
Put data into final internal table from different internal tables
LOOP AT IT_MARA INTO WA_MARA.
LOOP AT IT_PLAF INTO WA_PLAF WHERE MATNR = WA_MARA-MATNR.
READ TABLE IT_ZCDR_D
INTO WA_ZCDR_D
WITH KEY PLNUM = WA_PLAF-PLNUM.
IF SY-SUBRC <> 0.
MOVE WA_PLAF-PLNUM TO WA_PLAF_MAKT-PLNUM.
MOVE WA_PLAF-MATNR TO WA_PLAF_MAKT-MATNR.
MOVE WA_PLAF-KDAUF TO WA_PLAF_MAKT-KDAUF.
MOVE WA_PLAF-KDPOS TO WA_PLAF_MAKT-KDPOS.
READ TABLE IT_AFPO INTO WA_AFPO WITH KEY PLNUM = WA_PLAF-PLNUM.
MOVE WA_AFPO-AUFNR TO WA_PLAF_MAKT-AUFNR.
SELECT
SINGLE * FROM VSAUFK
INTO TABLE IT_VSAUFK
WHERE AUFNR = WA_AFPO-AUFNR
AND STAT = 'I0012'.
IF SY-SUBRC <> 0.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ELSE.
CHECK IT_VSAUFK-INACT = 'X'.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ENDIF.
ENDLOOP.
READ TABLE IT_MAKT
INTO WA_MAKT
WITH KEY MATNR = WA_MARA-MATNR.
MOVE WA_MAKT-MAKTX TO WA_PLAF_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT.
CLEAR WA_PLAF_MAKT.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT IT_PLAF_MAKT .
LOOP AT IT_MARA INTO WA_MARA.
LOOP AT IT_PLAF INTO WA_PLAF WHERE MATNR = WA_MARA-MATNR.
LOOP AT IT_AFPO INTO WA_AFPO WHERE MATNR = WA_MARA-MATNR.
READ TABLE IT_ZCDR_D
INTO WA_ZCDR_D
WITH KEY PLNUM = WA_AFPO-PLNUM.
IF SY-SUBRC <> 0.
LOOP AT IT_AFPO INTO WA_AFPO.
WHERE MATNR IN SO_MATNR
AND STRMP = SO_PERTR
AND PLNUM IN SO_PLNUM
AND KDAUF IN SO_-KDAUF
AND MATKL IN SO_MATKL.
SELECT
SINGLE INACT FROM VSAUFK
INTO WA_VSAUFK
WHERE AUFNR = WA_AFPO-AUFNR
AND STAT = 'I0012'.
IF SY-SUBRC <> 0.
WA_PLAF_MAKT-PLNUM = WA_AFPO-PLNUM.
WA_PLAF_MAKT-KDAUF = WA_AFPO-KDAUF.
WA_PLAF_MAKT-KDPOS = WA_AFPO-KDPOS.
WA_PLAF_MAKT-MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-AUFNR = WA_AFPO-AUFNR.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-MAKTX = WA_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT .
APPEND WA_AFPO TO IT_PLAF_MAKT.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ELSE.
CHECK WA_VSAUFK-INACT = 'X'.
WA_PLAF_MAKT-PLNUM = WA_AFPO-PLNUM.
WA_PLAF_MAKT-KDAUF = WA_AFPO-KDAUF.
WA_PLAF_MAKT-KDPOS = WA_AFPO-KDPOS.
WA_PLAF_MAKT-MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-AUFNR = WA_AFPO-AUFNR.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR = WA_AFPO-MATNR.
WA_PLAF_MAKT-MAKTX = WA_MAKT-MAKTX.
APPEND WA_PLAF_MAKT TO IT_PLAF_MAKT .
APPEND WA_AFPO TO IT_PLAF_MAKT.
MOVE WA_AFPO-AUFNR TO IT_PLAF_MAKT-AUFNR.
ENDIF.
ENDIF.
ENDLOOP.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT.
WA_PLAF_MAKT-CBNO = PR_CBNO.
MODIFY IT_PLAF_MAKT FROM WA_PLAF_MAKT TRANSPORTING CBNO.
ENDLOOP.
ENDLOOP.
PERFORM CHANGE_CATALOG.
PERFORM ALV_DISPLAY.
*& Form CHANGE_CATALOG
text
FORM CHANGE_CATALOG.
LAYOUT-ZEBRA = 'X'.
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
WA_FIELDCAT-col_pos = L_POS.
WA_FIELDCAT-SELTEXT_M = 'Planned Order Nos.'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'PLNUM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-INPUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'Check Box'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = abap_true.
WA_FIELDCAT-FIELDNAME = 'CHK'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '12'.
WA_FIELDCAT-SELTEXT_M = 'Material'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '35'.
WA_FIELDCAT-SELTEXT_M = 'Material Description'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'MAKTX'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-SELTEXT_M = 'Sales Order Number'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'KDAUF'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-SELTEXT_M = 'S O Line Item'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'KDPOS'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
L_POS = L_POS + 1.
WA_FIELDCAT-COL_POS = L_POS.
WA_FIELDCAT-OUTPUTLEN = '13'.
WA_FIELDCAT-SELTEXT_M = 'Production Order'.
WA_FIELDCAT-TABNAME = WA_PLAF_MAKT.
WA_FIELDCAT-FIELDNAME = 'AUFNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
*GS_LAYOUT-TOTALS_BEFORE_ITEMS = 'X'.
*data : text like slis_ev_subtotal_text value 'total'.
*gs_layout-subtotals_text = text.
*gs_layout-totals_only = 'X'.
gs_layout-subtotals_text = 'total'.
endform. " CHANGE_CATALOG
*********************event*************************************
*& Form ALV_DISPLAY
text
FORM ALV_DISPLAY.
*data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'PLANNED ORDERS'
I_GRID_SETTINGS = LC_GLAY
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT =
IT_EVENTS = IT_EVENTS[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_IT_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_PLAF_MAKT
EXCEPTIONS
PROGRAM_ERROR = 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.
REFRESH IT_FIELDCAT[].
ENDFORM. "ALV_DISPLAY
*& Form USER_COMMAND
text
-->UCOMM text
-->SELFIELD text
FORM USER_COMMAND
USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
Data: REF1 TYPE REF TO CL_GUI_ALV_GRID.
DATA WA LIKE LINE OF IT_PLAF_MAKT.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF1.
CALL METHOD REF1->CHECK_CHANGED_DATA.
CASE UCOMM.
WHEN '&BACK'.
LEAVE TO SCREEN 0.
WHEN '&EXIT'.
LEAVE TO SCREEN 0.
WHEN '&CANC'.
LEAVE TO SCREEN 0.
WHEN '&SAVE'.
CLEAR IT_ZCDR_D[].
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT WHERE CHK = 'X'.
CLEAR WA_ZCDR_D.
WA_ZCDR_D-MANDT = SY-MANDT.
WA_ZCDR_D-CBNO = WA_PLAF_MAKT-CBNO.
WA_ZCDR_D-plnum = WA_PLAF_MAKT-PLNUM.
WA_ZCDR_D-MATNR = WA_PLAF_MAKT-MATNR.
WA_ZCDR_D-MAKTX = WA_PLAF_MAKT-MAKTX.
WA_ZCDR_D-KDAUF = WA_PLAF_MAKT-KDAUF.
WA_ZCDR_D-KDPOS = WA_PLAF_MAKT-KDPOS.
WA_ZCDR_D-AUFNR = WA_PLAF_MAKT-AUFNR.
APPEND WA_ZCDR_D to IT_ZCDR_D.
ENDLOOP.
LOOP AT IT_ZCDR_D INTO WA_ZCDR_D.
INSERT ZCDR_D FROM WA_ZCDR_D.
CLEAR WA_ZCDR_D.
ENDLOOP.
IF SY-SUBRC EQ 0.
MESSAGE S021(ZCBR) WITH PR_CBNO.
ENDIF.
IF IT_ZCDR_D IS INITIAL.
MESSAGE 'Select Atleast one Check Box' TYPE 'E' .
ENDIF.
WHEN 'IMPORT_INF'.
PERFORM IMPORT_REPORT.
WHEN 'EXPORT_INF'.
PERFORM EXPORT_REPORT.
WHEN 'UNIT_CONSU'.
PERFORM UNIT_CONSUMPTION.
ENDCASE.
ENDFORM. "USER_COMMAND
FORM set_events USING it_events TYPE slis_t_event.
DATA: x_event TYPE slis_alv_event.
clear x_event.
x_event-name = 'USER_COMMAND'.
x_event-form = 'USER_COMMAND'.
append x_event to it_events.
CLEAR x_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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.
read table it_events into x_event with key name = slis_ev_user_command.
if sy-subrc = 0.
x_event-form = 'USER_COMMAND'.
modify it_events from x_event index sy-tabix transporting form .
endif.
ENDFORM.
*& Form set_pf_status
text
-->RT_EXTAB text
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z_PFSTAT'.
ENDFORM. " set_pf_status
FORM IMPORT_REPORT.
TYPES: BEGIN OF TY_BOM,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
VPRSV LIKE STPOX-VPRSV,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_BOM,
BEGIN OF TY_QUAN,
MATMK LIKE STPOX-MATMK,
MTNRV LIKE ZCDR_D-MATNR,
IDNRK LIKE STPOX-IDNRK,
MNGLG LIKE STPOX-MNGLG,
MMEIN LIKE STPOX-MMEIN,
UPRICE LIKE MBEW-STPRS,
TPRICE LIKE MBEW-STPRS,
END OF TY_QUAN,
BEGIN OF TY_T023T,
MATKL LIKE T023T-MATKL,
WGBEZ LIKE T023T-WGBEZ,
END OF TY_T023T,
BEGIN OF TY_T006A,
MMEIN LIKE T006A-MSEHI,
MSEHT LIKE T006A-MSEHT,
END OF TY_T006A,
BEGIN OF TY_IMP_FINAL,
SNO TYPE SY-INDEX,
HSCODE LIKE ZHSCODE-HSCODE,
WGBEZ TYPE T023T-WGBEZ,
SPEC(20) TYPE C,
MNGLG LIKE STPOX-MNGLG,
MSEHT LIKE T006A-MSEHT,
CNTRY(13) TYPE C,
UPRICE TYPE P LENGTH 16 DECIMALS 2,
TPRICE TYPE P LENGTH 16 DECIMALS 2,
CURRCODE TYPE C LENGTH 5,
END OF TY_IMP_FINAL,
BEGIN OF TY_MBEW,
MATNR LIKE MBEW-MATNR,
VPRSV LIKE MBEW-VPRSV,
STPRS LIKE MBEW-STPRS,
VERPR LIKE MBEW-VERPR,
END OF TY_MBEW.
DATA: WA_BOM TYPE TY_BOM,
WA_QUAN TYPE TY_QUAN,
WA_IMP_FINAL TYPE TY_IMP_FINAL,
WA_T023T TYPE TY_T023T,
WA_T006A TYPE TY_T006A,
WA_MBEW TYPE TY_MBEW.
DATA: IT_BOM TYPE TABLE OF TY_BOM,
IT_QUAN TYPE TABLE OF TY_QUAN,
IT_IMP_FINAL TYPE TABLE OF TY_IMP_FINAL,
IT_MBEW TYPE TABLE OF TY_MBEW.
DATA: IT_STPO TYPE STANDARD TABLE OF STPOX,
WA_STPO TYPE STPOX.
SELECT
MATNR
VPRSV
STPRS
VERPR
FROM MBEW
INTO CORRESPONDING FIELDS OF TABLE IT_MBEW.
WHERE MATNR EQ IT_MARA-MATNR. "MBEW
*I_STPO2 TYPE STANDARD TABLE OF STPOX.
LOOP AT IT_PLAF_MAKT INTO WA_PLAF_MAKT WHERE CHK = 'X'.
LOOP AT IT_ZCDR_D INTO WA_ZCDR_D .
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2' -
BRFplus: Problem updating values in an internal table in a loop expression
Hi
I'm looking into the loop expression type of BRFplus and I have come across a problem updating an internal table, I'm trying to create and populate the table using a loop, here is the functionality I'm trying to achieve:
In a rule set create an internal MONTH_TBL table containing 12 rows of two columns: MONTH_NUM containing values 1 through 12 and MONTH_VAL containing an amount (initially 0,00 EUR in all 12 rows).
After initializing the table traverse through SFLIGHT table and for each row add PRICE from the table to MONTH_VAL in the row of MONTH_TBL corresponding to the month of FLDATE field in SFLIGHT.
The initialization of MONTH_TBL works as intended, as does the traversal of and retrieval of values from SFLIGHT. The problem however is the update of the internal table MONTH_TBL (defined as result data object for the function). I don't get an error, but the tables does not get updated, and I cannot seem to find out what the problem is. I would have attached an XML extract of the function + ruleset for information, but it dosen't seem like that is possible, I could e-mail it on request (for SAP employees with access to system QU5 the function is LOOP_TEST in application Z_KLAUS_TEST).
I hope that this is sufficient information to understand the issue that I'm dealing with.
best regards
Klaus Stenbæk, KMDHi Klaus,
The Loop expression is part of NW 7.02 which is not yet released. When you experience the problem as part of a test you should have a contact at SAP for dealing with problems/errors. Usually SAP-internal messages are used for this purpose. Please clarify with your SAP contact how the model is.
BR,
Carsten -
Grouping of rows of internal table.
Hi all,
I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
This pointer variable will then be passed to ALV.
Help reqd.
regards.hi,
AT - itab:
push F1 to look at the documentation for grouping
then assign the value to a field-symbol. -
URGENT:Problem in a mapping with 8 tables in JOIN and using the DEDUP op.
I have an urgent problem with a mapping: I must load data from 8 source tables (joined togheter) in a target table.
Some data from 1 of the 8 tables have to be deduplicated, so I created a sort of staging table where I inserted the "cleaned" data, I mean, the deduplicated ones.
I made it to make all the process faster.
Then, I joined the 8 tabled, writing the join conditions in the operator properties, and connected the outputs into the fields of the target table.
But..it does not work because this kind of mapping create a cartesian product.
Then, I tried again with another mapping builted up in this way: after the joiner operator, I used the Match-Merge Operator and I load all data into a staging table exactly alike the target one, except for the PK (because it is a sequence). Then, I load the data from this staging table into the target one, and, of course, I connect to the target table also the sequence (the primary key). The first loading works fine (and load all the data as I expected).
For the next loadings,I scheduled a pre-mapping process that truncate the staging table and re-load the new data.
But..it does not work. I mean, It doesn't update the data previously loaded (or inser the new ones), but only insert the data, not considering the PK.
So, my questions are as follow:
1) Why loading the data directly from the joiner operator into the fact table doesn't work? Why does it generate a cartesian product??
2) The "escamotage" to use the Match-Merge operator is correct? I have to admit that I didn't understand very well the behaviour of this operator...
3) And, most of all, HOW CAN I LOAD MY DATA? I cannot find a way out....First of all, thanks for the answer!
Yes, I inserted the proper join condition and in fact I saw that when WB generates the script it considers my join but, instead of using the fields in a single select statement, it builts up many sub-selects. Furthermore, it seems as it doesn't evaluate properly the fields coming from the source tables where I inserted the deduplicated data...I mean, the problems seems not to be the join condition, but the data not correctly deduplicated.. -
Problem reading data from nested internal table.
Hi,
Below is my code;
*********SAP Code********
TYPES: BEGIN OF v54a0_scdd,
fknum LIKE vfkk-fknum,
change LIKE vfkkd-updkz,
x TYPE v54a0_scd,
y TYPE v54a0_scd,
tvtf LIKE tvtf,
END OF v54a0_scdd.
SCD table for dialog
TYPES: v54a0_scdd_tab TYPE v54a0_scdd OCCURS 1.
*********SAP Code********
*Custom declaration*****
data: wa_freight_costs type v54a0_scdd_tab.
data: it_freight_costs type v54a0_scdd_tab occurs 0.
*****Here data is getting appended to it_freight_costs. P_frieght_costs is coming from standard program.
move p_freight_costs TO wa_FREIGHT_COSTS.
append wa_freight_costs to it_freight_costs.
clear wa_freight_costs.
***Now the problem is here. I am not able to read the data from the nested internal table x-item.
if i use <fs_f_costs> to move data from it_freight_costs in the outer loop, i get a syntax error; <i> "the line type of the table it_freight_costs is not compatible with field symbol type <fs_f_costs>" </i>
FIELD-SYMBOLS: <fs_f_costs> type line of v54a0_scdd_tab.
LOOP AT it_freight_costs assigning <fs_f_costs>.
LOOP AT <fs_f_costs>-x-item ASSIGNING <fs_freight_item>.
<b> I want to read <fs_freight_item>-vfkp-netwr.</b>
ENDLOOP.
Can anyone guide me?A quick look at how I would do this. Note I haven't checked if this compiles just done a quick brain-dump.
DATA: lr_f_costs TYPE REF TO v54a0_scdd_tab,
lr_f_cost TYPE REF TO v54a0_scdd.
LOOP AT it_freight_costs REFERENCE INTO lr_f_costs.
LOOP AT lr_f_costs->* REFERENCE INTO lr_f_cost.
ENDLOOP.
ENDLOOP.
As you can see I personally prefer pointers to field symbols - I don't believe there is any performance differences and because of my background in other languages pointers make more sense to me.
Cheers
Graham Robbo -
Grouping records in an internal table
Dear all,
Pls follow the code and suggest me to get the specified format.
Consider that i have created a view to populate the reqd data and collect those in an internal table and do a calculation for one field and modify the internal table.
when i pass this internal table to the function reuse_alv_grid , it throws out a report. But if i need to group the records of the internal table based on three fields, can i do that , if so , how should i do that, if not what method shud i adopt to get the grouped listing in ALV.
kindly give your views.
Code goes here..........
select distinct edatu j_3akvgr6 mvgr4 matnr bismt vbeln auart bstkd bstkd_e ihrez_e
bstdk_e bstdk bezei vrvez brgew ntgew volum werks kwmeng j_3asize posnr
INTO CORRESPONDING FIELDS OF TABLE itabdelshd
from ZVDELISHED
where J_3AKVGR6 IN CUSTOMER AND AUART IN ORDTYP
AND BISMT IN STYLE AND MATNR in FGMtrl AND bstdk_e IN PLNDATE
AND J_3ASIZE IN GRIDVAL and werks in plant and mvgr4 in ppmon and
bstkd in cpono and vbeln in Sales.
LOOP AT itabdelshd INTO wadelshd.
select sum( wmeng ) as tqty into wasumqty-tqty
from vbep where edatu = wadelshd-edatu and vbeln = wadelshd-vbeln
and j_3asize = wadelshd-j_3asize.
select sum( lfimg ) as dqty into wasumqty-dqty
from lips where vbelv = wadelshd-vbeln and j_3asize = wadelshd-j_3asize
wadelshd-PLND_QTY = wasumqty-tqty - wasumqty-dqty.
wadelshd-PLND_QTY = wadelshd-wmeng - wadelshd-lfimg.
wadelshd-COLOR = wadelshd-j_3asize(4).
MODIFY itabdelshd FROM wadelshd.
ENDLOOP.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.Dear Jorge,
It is working out, But i need to do the sum for the grouped data, for instance , if the below data is grouped data seen in the alv,
sales ord | color line.Item| Ord.qty | Pld.Qty | Date "
| 0001000551 | 002V | 100 | 6,800.000 | 1,200.000 | 25.09.2006"
| 0001000551 | 002V | 100 | 6,800.000 | 2,500.000 | 25.09.2006"
| 0001000551 | 002V | 100 | 6,800.000 | 3,100.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 700.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 1,200.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 3,200.000 | 1,300.000 | 25.09.2006"
and if want to sum the the planed qty based on the line.Item Grouping, meaning, can i get the report in the below form.
sales ord | color line.Item| Ord.qty | Pld.Qty | Date "
| 0001000551 | 002V | 100 | 6,800.000 | 6,800.000 | 25.09.2006"
| 0001000551 | 003K | 200 | 6,800.000 | 3,200.000 | 25.09.2006"
what should i do to get this form.
Maybe you are looking for
-
Unicode in Oracle 8i and Oracle XE
I'm developing a program to read database objects and data of Oracle Database from Oracle 8.1.7 and store everything as XML files and then read these XML file on different computer and built the same database on Oracle XE and import the data in to it
-
F-58 Print check without check lot number
Hi experts, I am testing the check printing function via F-58. The scenario would be without the check lot number because user will manually feed the check into the printer while printing. But as i test in F-58, system keep forcing me to enter the ch
-
Am I going mad? Passing values between blocks seems impossible...
Hello, I am having extreme difficulty getting the most basic of oracle forms functionality to work, and am starting to go mad. All I want to do is pass a value between blocks, with said value being used as part of a query to populate a block. E.g. SE
-
i buy one iphone 4 in ebay locked to une swedish netwoork.telia. haw i can unlock this phone in uk.is not black listed
-
Error When Downloading Config via TFTP
I have 2 different 4400 series controllers running vastly different version of code (7.0.98.0 & 4.1.185.0) that both give me this error when attempting to download the config via TFTP: "TFTP Code File type not supported!" I have successfully download