What happen if i use controll break statement in between select & endselect
Hi all,
what happen if i use controll break statement in between select & endselect ?
Thanks in Advance
KR
Hi for reference u can go through this code example
data:
fs_tab like sflight.
data:
t_tab like standard table of fs_tab.
select * from sflight into table t_tab.
loop at t_tab into fs_tab.
write: / fs_tab-carrid.
endloop.
refresh t_tab.
clear fs_tab.
select * from sflight into fs_tab.
at new fs_tab-carrid.
append fs_tab to t_tab.
endat.
endselect.
Similar Messages
-
How can I use control break statement in my requirement
Hi ABAPers,
In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
internal table fields :
audat prdha ipnum netwr
02 abc 1 100
02 abc 2 200
02 xyz 3 300
03 abc 4 100
03 xyz 5 300
03 xyz 6 200
i need output like this:
audat prdha ipnum netwr
02 abc 1,2 300
02 xyz 3 300
03 abc 4 100
03 xyz 5,6 500
Can anyone suggest me logic for this by using control break statements
Thanks in advance,
Ankita
Moderator Message: Duplciate Post.
Edited by: kishan P on Apr 14, 2011 3:03 PMHi ABAPers,
In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
internal table fields :
audat prdha ipnum netwr
02 abc 1 100
02 abc 2 200
02 xyz 3 300
03 abc 4 100
03 xyz 5 300
03 xyz 6 200
i need output like this:
audat prdha ipnum netwr
02 abc 1,2 300
02 xyz 3 300
03 abc 4 100
03 xyz 5,6 500
Can anyone suggest me logic for this by using control break statements
Thanks in advance,
Ankita
Moderator Message: Duplciate Post.
Edited by: kishan P on Apr 14, 2011 3:03 PM -
In alv report can i use control break events? if no .whay?
Hi all,
in alv report can i use control break events? if no .whay?hi,
you can use control break statements in ALV report.
for example: if one PO is having more than one line item, that time you need to display PO only once. -
Control break statements in smart forms
Hi,
Can we use control break statements(at new,at end of) in smart forms?
if no why?
if yes, how?
Regards,
Sonikayou can use control block statements in smartforms by using the SORT events.
In TABLES go to to the SORT section.Here you can give the field by which you want the table to be sorted.There are two radio buttons available for sort : SORT BEGIN and SORT end.
On selecting any one sort event are generated automatically and event nodes are created in smartforms.Inside these event nodes you can add text nodes or code nodes and write your code.
SORT BEGIN works like AT NEW
SORT END works like AT END OF. -
Control Break Statements in HR-ABAP
Hi Guru's
I'm new to hr-abap i would like some guidance, can we use control break statements in abap-hr.
Thanks & Regards
Raj.Hi Raj,
You mean AT .. ENDAT statements inside loops right?
Yes, they are definitely used in HR-ABAP.
REPORT ZTRIAL.
INFOTYPES: 0022.
GET PERNR.
LOOP AT P0022.
AT FIRST.
WRITE: 'First record'.
ENDAT.
AT NEW SLART.
WRITE: 'School type changed'.
ENDAT.
ENDLOOP.
Regards,
Dilek -
Bdc on vk11 using control break events
hi
have any one done bdc for vk11 using control break events.my flat file is
ZTAX X IN 1000 1200 2000 A0
ZTAX X IN 1000 1210 3000 A1
ZTAX X US 7676 01 4000 L3
ZTAX X US 7676 02 5000 s1
i need the logic for this any sample code will be usefulhi, check the sample code using Control break statements.
LOOP AT IT_MAIN.
WRITE : IT_MAIN.
C_TABIX = SY-TABIX.
<b>AT NEW LIFNR_001.</b>
READ TABLE IT_MAIN INDEX C_TABIX.
REFRESH IT_BDC.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-BSTNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKKO-LIFNR'
IT_MAIN-LIFNR_001.
perform bdc_field using 'RM06E-BSART'
IT_MAIN-BSART_002.
perform bdc_field using 'RM06E-BEDAT'
IT_MAIN-BEDAT_003.
perform bdc_field using 'EKKO-EKORG'
IT_MAIN-EKORG_004.
perform bdc_field using 'EKKO-EKGRP'
IT_MAIN-EKGRP_005.
perform bdc_field using 'RM06E-LPEIN'
IT_MAIN-LPEIN_006.
perform bdc_field using 'RM06E-WERKS'
IT_MAIN-WERKS_007.
MOVE 1 TO CNT.
<b>ENDAT.</b>
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-TXZ01(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CONCATENATE 'EKPO-EMATN(' CNT ')' INTO FLD.
perform bdc_field using FLD IT_MAIN-EMATN_01_008.
CONCATENATE 'EKPO-TXZ01(' CNT ')' INTO FLD.
perform bdc_field using FLD IT_MAIN-TXZ01_01_009.
CONCATENATE 'EKPO-MENGE(' CNT ')' INTO FLD.
perform bdc_field using FLD IT_MAIN-MENGE_01_010.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CNT = CNT + 1.
IF CNT = 6.
CNT = 1.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=P+'.
ENDIF.
<b>AT END OF LIFNR_001.</b>
READ TABLE IT_MAIN INDEX C_TABIX.
RECORD = IT_MAIN.
perform bdc_dynpro using 'SAPLSPO1' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'ME21' USING IT_BDC MODE 'A' MESSAGES INTO IT_MESSAGES.
clear: cnt, C_tabix .
<b>ENDAT.</b>
ENDLOOP. -
Hi friends,
pls explain , what is the use of control break statements( at first, at last, at new, at end of, on change of ) ? and practical difference applying at new and on change.
Pls send me material or links related to control break statements.
Thanks in advance.
SR KHello SR K,
Just go through the following documentation.
AT - Control breaks with extracts
Variants:
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
5. AT fg.
Effect In a LOOP which processes a dataset created with EXTRACT, you
can use special control structures for control break
processing. All these structures begin with AT and end with
ENDAT. The sequence of statements which lies between is
executed whenever a control break occurs.
You can use these key words for control break processing with
extract datasets only if the active LOOP statement is
processing an extract dataset.
The control level structure with extract datasets is dynamic.
It corresponds exactly to the sort key of the extract dataset,
i.e. to the order of fields in the field group HEADER by which
the extract dataset was sorted.
At the end of a control group (AT END OF, AT LAST), there are
two types of control level information between AT and ENDAT:
- If the sort key of the extract dataset contains a
non-numeric field h (particularly in the field group
HEADER), the field CNT(h) contains the number of control
breaks in the (subordinate) control level h.
- For extracted number fields g (see also ABAP Number Types),
the fields SUM(g) contain the relevant control totals.
Notes 1. The fields CNT(h) and SUM(g) can only be addressed after
they have been sorted. Otherwise, a runtime error may
occur.
2. The fields CNT(h) and SUM(g) are filled with the relevant
values for a control level at the end of each control group
(AT END OF, AT LAST), not at the beginning (AT FIRST, AT
NEW).
3. When calculating totals with SUM(g), the system
automatically chooses the maximum field sizes so that an
overflow occurs only if the absolute value area limits are
exceeded.
4. You can also use special control break control structures
with LOOPs on internal tables.
Variant 1 AT NEW f.
Variant 2 AT END OF f.
Effect f is a field from the field group HEADER. The enclosed
sequence of statements is executed if
- the field f occurs in the sort key of the extract dataset
(and thus also in the field group HEADER) and
- the field f or a superior sort criterion has a different
value in the current LOOP line than in the preceding (AT
NEW) or subsequent (AT END OF) record of the extract
dataset.
If f is not an assigned field symbol, the control break
criterion is ignored, and the subsequent sequence of
statements is not executed. If a field symbol is assigned, but
does not point to the HEADER field group, the system triggers
a runtime error.
Example
DATA: NAME(30),
SALES TYPE I.
FIELD-GROUPS: HEADER, INFOS.
INSERT: NAME INTO HEADER,
SALES INTO INFOS.
LOOP.
AT NEW NAME.
NEW-PAGE.
ENDAT.
AT END OF NAME.
WRITE: / NAME, SUM(SALES).
ENDAT.
ENDLOOP.
Notes 1. If the extract dataset is not sorted before processing with
LOOP, no control level structure is defined and the
statements following AT NEW or AT END OF are not executed.
2. Fields which stand at hex zero are ignored by the control
break check with AT NEW or AT END OF. This corresponds to
the behavior of the SORT statement, which always places
unoccupied fields (i.e. fields which stand at hex zero)
before all occupied fields when sorting extract datasets,
regardless of whether the sort sequence is in ascending or
descending order.
Variant 3 AT FIRST.
Variant 4 AT LAST.
Effect Executes the relevant series of statements just once - either
on the first loop pass (with AT FIRST) or on the last loop
pass (with AT LAST).
Variant 5 AT fg.
Addition:
... WITH fg1
Effect This statement makes single record processing dependent on the
type of extracted record.
The sequence of statements following AT fg are executed
whenever the current LOOP record is created with EXTRACT fg
(in other words: when the current record is a fg record).
Addition ... WITH fg1
Effect Executes the sequence of statements belonging to AT fg WITH
fg1 only if the record of the field group fg in the dataset is
immediately followed by a record of the field group fg1.
Reward If Helpful
Regards
Sasidhar Reddy Matli. -
Control-break statements:value not being displayed.
Hi all,
Iam using the control break statement at end of ..., sum.
value is not being displayed,instead it is showing *********.
even in the debugging mode the value is not being displayed.
iam passing the values into a temp IT,but still the values are not being dispalyed.
here is the following snippet of code.
what could be the mistake?
Please give me the suitable answer.
Thanks in advance.
LOOP AT FT_ITAB INTO FT_WA.
FTY_WA-EBELN = FT_WA-EBELN.
FTY_WA-EBELP = FT_WA-EBELP.
FTY_WA-NAME1 = FT_WA-NAME1.
FTY_WA-ZTERM = FT_WA-ZTERM.
FTY_WA-INCO1 = FT_WA-INCO1.
FTY_WA-WAERS = FT_WA-WAERS.
FTY_WA-SUBMI = FT_WA-SUBMI.
AT END OF EBELN.
SUM.
FTY_WA-BRTWR = FT_WA-BRTWR.
FTY_WA-KTMNG = FT_WA-KTMNG.
FTY_WA-NETPR = FT_WA-NETPR.
APPEND FTY_WA TO FTY_ITAB.
CLEAR FTY_WA.
ENDAT.Abhi,
i tried as you said values are being diplayed,but they are not gettin totaled,i want the sum of values at the end of line item,I need to pass these valuse to alv.
here is the complete code.Please tell me how should I proceed.
TABLES:EKKO,EKPO,LFA1.
TYPE-POOLS:SLIS.
DATA:HEADER TYPE SLIS_T_FIELDCAT_ALV,
WA TYPE SLIS_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV.
TYPES:BEGIN OF PH_TY,
PH_EBELN LIKE EKKO-EBELN,
PH_AEDAT LIKE EKKO-AEDAT,
PH_LIFNR LIKE EKKO-LIFNR,
PH_ZTERM LIKE EKKO-ZTERM,
PH_EKORG LIKE EKKO-EKORG,
PH_WAERS LIKE EKKO-WAERS,
PH_SUBMI LIKE EKKO-SUBMI,
PH_INCO1 LIKE EKKO-INCO1,
PO_EBELN LIKE EKPO-EBELN,
PO_EBELP LIKE EKPO-EBELP,
PO_BRTWR LIKE EKPO-BRTWR,
PO_KTMNG LIKE EKPO-KTMNG,
PO_NETPR LIKE EKPO-NETPR,
END OF PH_TY.
TYPES:BEGIN OF PO_TY,
PO_EBELN LIKE EKPO-EBELN,
PO_EBELP LIKE EKPO-EBELP,
PO_BRTWR LIKE EKPO-BRTWR,
PO_KTMNG LIKE EKPO-KTMNG,
PO_NETPR LIKE EKPO-NETPR,
END OF PO_TY.
TYPES:BEGIN OF VO_TY,
VO_LIFNR LIKE LFA1-LIFNR,
VO_NAME1 LIKE LFA1-LIFNR,
END OF VO_TY.
TYPES:BEGIN OF FI_TY,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
LIFNR LIKE EKKO-LIFNR,
ZTERM LIKE EKKO-ZTERM,
EKORG LIKE EKKO-EKORG,
WAERS LIKE EKKO-WAERS,
SUBMI LIKE EKKO-SUBMI,
INCO1 LIKE EKKO-INCO1,
EBELN_I LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
NAME1 LIKE LFA1-LIFNR,
BRTWR LIKE EKPO-EBELN,
KTMNG LIKE EKPO-EBELN,
NETPR LIKE EKPO-EBELN,
LIFNR1 LIKE LFA1-LIFNR,
END OF FI_TY.
TYPES:BEGIN OF FT_TY,
EBELN LIKE EKKO-EBELN,
ZTERM LIKE EKKO-ZTERM,
WAERS LIKE EKKO-WAERS,
SUBMI LIKE EKKO-SUBMI,
INCO1 LIKE EKKO-INCO1,
EBELP LIKE EKPO-EBELP,
NAME1 LIKE LFA1-LIFNR,
BRTWR LIKE EKPO-EBELN,
KTMNG LIKE EKPO-EBELN,
NETPR LIKE EKPO-EBELN,
END OF FT_TY.
DATA: PH_ITAB TYPE STANDARD TABLE OF PH_TY,
PO_ITAB TYPE STANDARD TABLE OF PO_TY,
VO_ITAB TYPE STANDARD TABLE OF VO_TY,
FI_ITAB TYPE STANDARD TABLE OF FI_TY,
FT_ITAB TYPE STANDARD TABLE OF FT_TY,
FTY_ITAB TYPE STANDARD TABLE OF FT_TY,
FTY1_ITAB TYPE STANDARD TABLE OF FT_TY.
DATA:PH_WA LIKE LINE OF PH_ITAB,
PO_WA LIKE LINE OF PO_ITAB,
VO_WA LIKE LINE OF VO_ITAB,
FI_WA LIKE LINE OF FI_ITAB,
FT_WA LIKE LINE OF FT_ITAB,
FT_WA1 LIKE LINE OF FT_ITAB,
FTY_WA LIKE LINE OF FT_ITAB,
FTY1_WA LIKE LINE OF FT_ITAB.
SELECT A~EBELN
A~AEDAT
A~LIFNR
A~ZTERM
A~EKORG
A~WAERS
A~SUBMI
A~INCO1
B~EBELN
B~EBELP
B~BRTWR
B~KTMNG
B~NETPR
INTO TABLE PH_ITAB FROM EKKO AS A
INNER JOIN EKPO AS B
ON AEBELN = BEBELN
UP TO 25 ROWS.
CHECK PH_ITAB[] IS NOT INITIAL.
SELECT LIFNR
NAME1
FROM LFA1 INTO TABLE VO_ITAB
FOR ALL ENTRIES IN PH_ITAB
WHERE LIFNR = PH_ITAB-PH_LIFNR.
CHECK VO_ITAB[] IS NOT INITIAL.
SORT PH_ITAB BY PH_EBELN.
SORT VO_ITAB BY VO_LIFNR.
LOOP AT PH_ITAB INTO PH_WA.
FI_WA-SUBMI = PH_WA-PH_SUBMI.
FI_WA-EBELN = PH_WA-PH_EBELN.
FI_WA-ZTERM = PH_WA-PH_ZTERM.
FI_WA-INCO1 = PH_WA-PH_INCO1.
FI_WA-WAERS = PH_WA-PH_WAERS.
FI_WA-EBELP = PH_WA-PO_EBELP.
FI_WA-BRTWR = PH_WA-PO_BRTWR.
FI_WA-KTMNG = PH_WA-PO_KTMNG.
FI_WA-NETPR = PH_WA-PO_NETPR.
READ TABLE VO_ITAB INTO VO_WA WITH KEY VO_LIFNR = PH_WA-PH_LIFNR BINARY SEARCH.
FI_WA-NAME1 = VO_WA-VO_NAME1.
APPEND FI_WA TO FI_ITAB.
CLEAR FI_WA.
ENDLOOP.
LOOP AT FI_ITAB INTO FI_WA.
FT_WA-EBELN = FI_WA-EBELN.
FT_WA-EBELP = FI_WA-EBELP.
FT_WA-NAME1 = FI_WA-NAME1.
FT_WA-ZTERM = FI_WA-ZTERM.
FT_WA-INCO1 = FI_WA-INCO1.
FT_WA-WAERS = FI_WA-WAERS.
FT_WA-SUBMI = FI_WA-SUBMI.
FT_WA-BRTWR = FI_WA-BRTWR.
FT_WA-KTMNG = FI_WA-KTMNG.
FT_WA-NETPR = FI_WA-NETPR.
APPEND FT_WA TO FT_ITAB.
CLEAR FT_WA.
ENDLOOP.
LOOP AT FT_ITAB INTO FT_WA.
AT END OF EBELN.
SUM.
FTY_WA-EBELN = FT_WA-EBELN.
FTY_WA-EBELP = FT_WA-EBELP.
FTY_WA-NAME1 = FT_WA-NAME1.
FTY_WA-ZTERM = FT_WA-ZTERM.
FTY_WA-INCO1 = FT_WA-INCO1.
FTY_WA-WAERS = FT_WA-WAERS.
FTY_WA-SUBMI = FT_WA-SUBMI.
FTY_WA-BRTWR = FT_WA-BRTWR + FTY_WA-BRTWR.
FTY_WA-KTMNG = FT_WA-KTMNG + FTY_WA-KTMNG.
FTY_WA-NETPR = FT_WA-NETPR + FTY_WA-KTMNG.
ENDAT.
APPEND FTY_WA TO FTY_ITAB.
CLEAR FTY_WA.
ENDLOOP.
WA-SELTEXT_L = 'ebeln'.
WA-COL_POS = '1'.
WA-FIELDNAME = 'EBELN'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'SUBMI'.
WA-COL_POS = '2'.
WA-FIELDNAME = 'SUBMI'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'NAME1'.
WA-COL_POS = '3'.
WA-FIELDNAME = 'NAME1'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'ZTERM'.
WA-COL_POS = '4'.
WA-FIELDNAME = 'ZTERM'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'INCO1'.
WA-COL_POS = '5'.
WA-FIELDNAME = 'INCO1'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'WAERS'.
WA-COL_POS = '6'.
WA-FIELDNAME = 'WAERS'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '15'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'brtwr'.
WA-COL_POS = '7'.
WA-FIELDNAME = 'BRTWR'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '20'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'netpr'.
WA-COL_POS = '8'.
WA-FIELDNAME = 'NETPR'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '20'.
APPEND WA TO HEADER.
CLEAR WA.
WA-SELTEXT_L = 'ktmng'.
WA-COL_POS = '9'.
WA-FIELDNAME = 'KTMNG'.
WA-TABNAME = 'FTY_ITAB'.
WA-OUTPUTLEN = '20'.
APPEND WA TO HEADER.
CLEAR WA.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = header[]
TABLES
T_OUTTAB = FTY_ITAB[].
IF SY-SUBRC = 0.
ENDIF. -
Problem with the control break statement - AT END OF
data : IT_DATA TYPE STANDARD TABLE OF /BIC/OH0SPA_OHD WITH KEY /B28/S_D1DVOX5 ,
FIELD-SYMBOLS : <ls_data> TYPE any,
SELECT * FROM (c_open_hub) INTO TABLE IT_DATA .
*IF sy-subrc = 0.
*ENDIF.
Create the GUID for header
CALL FUNCTION 'GUID_CREATE'
IMPORTING
EV_GUID_32 = LV_GUID.
TRY.
CALL METHOD CL_GDT_CONVERSION=>GUID_OUTBOUND
EXPORTING
IM_GUID_C = LV_GUID
IMPORTING
EX_VALUE = LV_UUID.
CATCH CX_GDT_CONVERSION INTO go_exc .
gv_text = go_exc->get_text( ).
Application log for errors
IF gv_text IS NOT INITIAL.
PERFORM add_msg_to_log CHANGING lt_return.
CALL FUNCTION '/SPA/APPL_LOG'
EXPORTING
LV_OBJECT = '/SPA/APPL'
LV_SUBOBJECT = '/SPA/ESOA'
IT_RETURN = lt_return.
ENDIF.
ENDTRY.
OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-MESSAGE_HEADER-ID-CONTENT = LV_GUID.
OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-MESSAGE_HEADER-UUID-CONTENT = LV_UUID.
SELECT * FROM DD03T INTO TABLE lt_dd03t WHERE TABNAME = c_open_hub AND DDLANGUAGE = 'E' AND AS4LOCAL = 'A'.
*IF sy-subrc = 0.
*ENDIF.
Sort the delta table
SORT it_data.
populate the output structure
LOOP AT IT_DATA ASSIGNING <ls_data>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_keyfigures.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_keyfigures>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_signdata.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_signdata>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_bbtype.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_bbtype>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_customer.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_customer>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_product.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_product>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_territory.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_territory>.
READ TABLE lt_dd03t INTO ls_dd03t with KEY DDTEXT = c_time.
ASSIGN COMPONENT ls_dd03t-FIELDNAME OF STRUCTURE <ls_data> to <l_time>.
CASE <l_keyfigures>.
WHEN c_sd.
PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.
ls_period_term-start_date = lv_date.
WHEN c_ed.
PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.
ls_period_term-end_date = lv_date.
WHEN c_uplift.
LS_PRODUCT_KF-ID-CONTENT = c_uplift_qyts.
LS_PRODUCT_KF-VALUE = <l_signdata>.
LS_PRODUCT_KF-YEAR = lv_week(4).
LS_PRODUCT_KF-CALENDAR_PERIOD_ORDINAL_NUMBER = lv_week+4.
APPEND LS_PRODUCT_KF TO LT_PRODUCT_KF.
WHEN OTHERS.
PERFORM DATE_CALC USING <l_signdata> CHANGING LV_DATE.
ls_period_term-start_date = lv_date.
Get week
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = LS_PERIOD_TERM-START_DATE
IMPORTING
WEEK = LV_WEEK.
append Keyfigure
LS_PRODUCT_KF-ID-CONTENT = <l_keyfigures> .
LS_PRODUCT_KF-VALUE = <l_signdata>.
LS_PRODUCT_KF-YEAR = lv_week(4).
LS_PRODUCT_KF-CALENDAR_PERIOD_ORDINAL_NUMBER = lv_week+4.
APPEND LS_PRODUCT_KF TO LT_PRODUCT_KF.
append tradespend
SELECT SINGLE * FROM /SPA/SPEND_MAP INTO CORRESPONDING FIELDS OF LV_/SPA/SPEND_MAP
WHERE KEY_FIGURE = <l_keyfigures>.
IF sy-subrc = 0.
LS_TRADE_SPEND-TYPE_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_TYPE.
LS_TRADE_SPEND-CATEGORY_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_CATEGORY.
LS_TRADE_SPEND-METHOD_CODE-CONTENT = LV_/SPA/SPEND_MAP-SPEND_METHOD.
APPEND LS_TRADE_SPEND TO LT_TRADE_SPEND.
else.
lv_flg = 'X'.
ENDIF.
ENDCASE.
AT END OF /B28/S_D1DVOX5. "
SELECT SINGLE * FROM /SPA/SO_TER_MAP INTO LS_/SPA/SO_TER_MAP WHERE TERRITORY = <l_territory>.
IF sy-subrc = 0 AND lv_flg IS INITIAL.
Create the GUID for TP's
CALL FUNCTION 'GUID_CREATE'
IMPORTING
EV_GUID_32 = LV_GUID_MESSAGE.
TRY.
CALL METHOD CL_GDT_CONVERSION=>GUID_OUTBOUND
EXPORTING
IM_GUID_C = LV_GUID_MESSAGE
IMPORTING
EX_VALUE = LV_UUID_MESSAGE.
CATCH CX_GDT_CONVERSION .
ENDTRY.
populate the product
LS_PRODUCT-ID-CONTENT = <l_product>.
LS_CUSTOMER-ID-CONTENT = '300022'.
LS_CUSTOMER-ROLE_CODE = '00000105'.
LS_PRODUCT-KEY_FIGURE = LT_PRODUCT_KF.
APPEND LS_PRODUCT TO LT_PRODUCT.
APPEND LS_CUSTOMER TO LT_CUSTOMER.
APPEND LS_DESCRIPTION TO LT_DESCRIPTION.
APPEND LS_PERIOD_TERM TO LT_PERIOD_TERM.
LS_TRADE_PROMOTION-TRADE_PROMOTION-SALES_AREA-ORGANISATIONAL_CENTRE_ID = LS_/SPA/SO_TER_MAP-SALES__ORG.
LS_TRADE_PROMOTION-TRADE_PROMOTION-SALES_AREA-DISTRIBUTION_CHANNEL_CODE-CONTENT = LS_/SPA/SO_TER_MAP-DIST_CHANNEL.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_ACCOUNT-CUSTOMER_INTERNAL_ID = <l_customer>.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_PROFILE_GROUP_CODE-CONTENT = '4TPM'.
LS_TRADE_PROMOTION-TRADE_PROMOTION-TYPE_CODE-CONTENT = 'Z002'.
LS_TRADE_PROMOTION-TRADE_PROMOTION-UPLIFT_ACTIVE_INDICATOR = 'X'.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-MARKETING_PROJECT_PLANNING_PRO = '5'.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-CALENDAR_UNIT_CODE = 'WEE'.
LS_TRADE_PROMOTION-TRADE_PROMOTION-TRADE_SPEND = LT_TRADE_SPEND.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PARTY = LT_CUSTOMER.
LS_TRADE_PROMOTION-TRADE_PROMOTION-DESCRIPTION = LT_DESCRIPTION.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PLANNING_INFORMATION-PRODUCT = LT_PRODUCT.
LS_TRADE_PROMOTION-TRADE_PROMOTION-PERIOD_TERM = LT_PERIOD_TERM.
LS_TRADE_PROMOTION-MESSAGE_HEADER-ID-CONTENT = LV_GUID_MESSAGE.
LS_TRADE_PROMOTION-MESSAGE_HEADER-UUID-CONTENT = LV_UUID_MESSAGE.
LS_/SPA/REPORT_TAB-SPA_TP_ID = <l_bbtype>.
LS_/SPA/REPORT_TAB-MESSAGE_ID = LV_GUID_MESSAGE.
LS_/SPA/REPORT_TAB-CREATE_DATE = SY-DATUM.
INSERT /SPA/REPORT_TAB FROM LS_/SPA/REPORT_TAB.
APPEND LS_TRADE_PROMOTION TO LT_TRADE_PROMOTION.
OUTPUT-TRADE_PROMOTION_CRMBULK_CREATE-TRADE_PROMOTION_CRMCREATE_REQU = LT_TRADE_PROMOTION.
CLEAR : LT_DESCRIPTION, LT_PERIOD_TERM,LT_CUSTOMER, LT_PRODUCT, LT_PRODUCT_KF, LT_TRADE_SPEND,LS_/SPA/HEADER_TAB.
ENDIF.
CLEAR lv_flg .
ENDAT.
ENDLOOP.
My problem is AT-END OF STATEMENT IS executing for each and every record of same /B28/S_D1DVOX5.
Please help me from this problemHello,
First of all to know clearly about AT END.
Let's say In IT_DATA fields are F1 F2 F3 /B28/S_D1DVOX5 F5.
then AT END of /B28/S_D1DVOX5 means for each new value of this field at the end it will trigger.
Please ensure thet IT_DATA is sorted by this field and then used Control break.
Thanks,
Pramod -
At new control break statement
hi all,
I have a requirement where I have to display records for non duplicate matnr.
I have used this control break statement and got
stars for all other fields except matn in the outputr.
code: at new matnr.
write: /10 sy-vline , wa_mara-matnr COLOR 5,
30 sy-vline , wa_mara-ersda COLOR 5 ,
50 sy-vline , wa_mara-ernam COLOR 5 ,
70 sy-vline , wa_mara-laeda COLOR 5 ,
90 sy-vline , wa_mara-mtart COLOR 5 ,
110 sy-vline , wa_mara-matkl COLOR 5 ,
130 sy-vline , wa_mara-meins COLOR 5 ,
150 sy-vline.
ENDAT.
plese do send me solution for this.
with regards,
ASHA.FAQ. This has been discussed many times in the forum. Please search.
-
How to catch the value in sum(control break statement).
hi,
can any one tell me how to catch the value in sum in control break satament.
ex.
at end of brtwr.
sum.
endat.
I need to print the value in sum only.
I tried to declare a varaible of type i and assigned sum to this variable.
it is giving syntax error that sum is not identified.
How should i do this.
regards.Hi Siva,
In control break statement when we use SUM. it added all the amount fields and stores its in the work area of that field.
look below code.
DATA : BEGIN OF itab OCCURS 0,
name(10),
num TYPE i,
END OF itab.
DATA : num TYPE i .
itab-name = 'salman'.
itab-num = 100.
APPEND itab.
itab-name = 'salman'.
itab-num = 200.
APPEND itab.
itab-name = 'akshay'.
itab-num = 500.
APPEND itab.
LOOP AT itab.
AT END OF name.
SUM.
WRITE : / itab-num.
ENDAT.
ENDLOOP.
here the SUM value is stored in Workarea,
the output will be 300 & 500.
regards
Kumar M -
Doubt in control break statement
Hi All,
Is there any way to trigger control break statements at new & at end of for non primary key fields.
i want to trigger both control break statements for my requirement , not at change of, because i want to trigger at end of also. Please let me know if any possibility. Thanks
regards
vishalhi vishal,
Variants:
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
Effect
In a LOOP which processes an internal table, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between them is then executed if a control break occurs.
You can use these key words for control break processing with internal tables only if a loop is actively processing an internal table and reference is to the innermost currently active loop.
The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.
At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
All character type fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key.
Between AT and ENDAT, you can use SUM to insert the appropriate control totals in the numeric fields (see also ABAP Number Types) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level (AT FIRST, AT NEW f) and also the end of a control level (AT END OF f, AT LAST).
At the end of the control level processing (i.e. after ENDAT), the old contents of the LOOP output area are restored.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOPs on extracts, there are also special control break control structures you can use.
Note
Non-Catchable Exceptions:
SUM_OVERFLOW: Overflow when calculating totals with SUM.
Variant 1
AT NEW f.
Variant 2
AT END OF f.
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Compatible Work Area with Control Level Processing and Field Symbols Not Allowed as Control Level Criterion.
Effect
f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before fhas a different value than in the preceding (AT NEW) or subsequent (AT END OF) table line.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / WA_COMPANIES-NAME.
ENDAT.
WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME.
Notes
If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
If you use AT within a LOOP with an explicitly-specified output area, the area must be compatible with the line type of the internal table so that it can be initialized properly (as described above) at the start of a new control level.
You can restrict control break criteria further, regardless of whether they were defined statically or dynamically, by specifying offset and/or length.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the appropriate sequence of statements once during the first (AT FIRST) or last (AT LAST) loop pass.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT FIRST.
SUM.
WRITE: 'Sum of all SALES:',
55 WA_COMPANIES-SALES.
ENDAT.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-PRODUCT,
55 WA_COMPANIES-SALES.
ENDLOOP. -
Control break statements in Scripts
Hi All
Please help me.
What are the control break statements are possible in SAP Scripts for Main Window.
Regards
PraveenThis gives over view of almost all control commands.
ADDRESS Formatting of addresses
BOTTOM, ENDBOTTOM Define footer text in a window
BOX, POSITION, SIZE Boxes, lines and shading
CASE, ENDCASE Case distinction
DEFINE Value assignment to text symbols
HEX, ENDHEX Hexadecimal values
IF, ENDIF Conditional text output
INCLUDE Include other texts
NEW-PAGE Explicit forms feed
NEW-WINDOW Next window MAIN
PRINT-CONTROL Insert print control character
PROTECT, ENDPROTECT Protect from page break
RESET Initialize outline paragraphs
SET COUNTRY Country-specific formatting
SET DATE MASK Formatting of date fields
SET SIGN Position of +/- sign
SET TIME MASK Formatting of time fields
STYLE Change style
SUMMING Summing variables
TOP Set header text in window MAIN -
Control Break Statements ----- Please Help me
I have some idea about the control-break statements(AT-ENDAT). Can any one please give me the example ?
Thanks in Advance. Points will be rewarded immediately.sample program for AT events
Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
DATA: BEGIN OF ITAB OCCURS 0,
F1 TYPE I,
F2(6) TYPE C,
F3(10) TYPE N,
F4(16) TYPE P DECIMALS 2,
END OF ITAB.
DATA: SUB_TOT(10) TYPE P DECIMALS 3.
**--1
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 30.
ITAB-F4 = '3000.00'.
APPEND ITAB.
CLEAR ITAB.
*--2
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
SORT ITAB BY F1.
LOOP AT ITAB.
AT FIRST.
WRITE: /35 ' MATERIAL DETAILS:'.
ULINE.
ENDAT.
AT NEW F1.
WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.
ULINE.
ENDAT.
WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
SUB_TOT = SUB_TOT + ITAB-F4.
AT END OF F1.
ULINE.
WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
CLEAR SUB_TOT.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: 'SUM:', ITAB-F4.
ULINE.
ENDAT.
ENDLOOP.
Reward points if helpful.
Rgds,
Abhishek -
In Control break statement, can i write the 5th column first?
<i>hi,
assaign it to a work area before control brk statemnt.
loop at itab.
wa =itab.
at new ..
write wa-...
endloop.
rgds
anver</i>
Yep, and that is exactly what I said...
Regards,
Rich Heilman
Maybe you are looking for
-
How can I load Soundtrack Pro 3 on OSX 10.7.5?
Every time I try to load Soundtrack Pro (within Logic Pro 9.1.8) I get the message "Soundtrack Pro cannot be opened because of a problem". Software is up to date on a Quad Core iMac. Can anyone help?
-
How I got my 7.2 crossgrade
I called Apple support on wed. I told them that I had just spent $3000 on a new MacPro and could not find the needed crossgrade. After telling me it was unavailable, I raised **** about buying a new computer for 3 G's and not being able to use it etc
-
How to remove background object in new pages?
How do I remove a background object on document issued from previous pages version? Before I could tick 'background object are selectable' or something like this... Now I cannot find anything comparable!
-
Writing/reading password protected zip/gzip files
Hello All, is there anyway in java that i can write/read password protected zip/gzip files?? thanks in advance.
-
Making JFrame Window Lose Focus to a Native Window
How can i from within the same JFrame code or another class with the JFrame reference make JFrame lose focus to another native window on the desktop. Any tips