Use of AT NEW statement
Hi,
In my program have written the code as
SORT gt_bsik BY lifnr belnr gjahr buzei.
DATA : gv_count TYPE i VALUE 0.
IF sy-subrc = 0.
LOOP AT gt_bsik.
AT NEW lifnr .
READ TABLE gt_lfb1 WITH KEY lifnr = gt_bsik-lifnr BINARY
SEARCH.
CLEAR lt_vendors.
lt_vendors-lifnr = gt_lfb1-lifnr.
ENDAT.
AT NEW belnr.
gv_new_invoice_ind = 'X'.
gt_bsik_copy-lifnr = gt_bsik-lifnr.
gt_bsik_copy-belnr = gt_bsik-belnr.
gt_bsik_copy-gjahr = gt_bsik-gjahr.
gt_bsik_copy-buzei = gt_bsik-buzei.
gv_count = gv_count + gt_bsik-buzei .
ENDAT.
the value of gt_bsik-buzei is coming as *** after passing tho AT NEW belnr stmt.Before that the value is correct only after passing tho it showing wrong value but the other fields are showing correct value .Whats the reason for this?
HI,
Between AT NEW and endat statements you would have the field contents as **** after the field for which you have used in AT NEW statement. For example if you have used the 3rd field in AT NEW statement then between AT NEW and ENDAT statements you can access the first 3 fields contents only.If you want to access any field after 3rd field then you have to take a Back Up of those fields before you enter in to AT statement. In your case declare a WA_BSIK of type GT_BSIK.
Data : wa_bsik LIKE gt_bsik.
Before you enter in to AT NEW statement transfer contents of gt_bsik to wa_bsik.
WA_BSIK = GT_BSIK.
Between AT NEW and ENDAT use the field contents of wa_bsik and not gt_bsik.
AT NEW belnr.
gv_new_invoice_ind = 'X'.
wa_bsik_copy-lifnr = wa_bsik-lifnr.
wa_bsik_copy-belnr = wa_bsik-belnr.
wa_bsik_copy-gjahr = wa_bsik-gjahr.
wa_bsik_copy-buzei = wa_bsik-buzei.
gv_count = gv_count + wa_bsik-buzei .
ENDAT.
Similar Messages
-
What is the use of at new statement?
What is the use of at new statement?
Hi,
AT - itab
Syntax
LOOP AT itab result ...
[AT FIRST.
ENDAT.]
[AT NEW comp1.
ENDAT.
[AT NEW comp2.
ENDAT.
AT END OF comp2.
ENDAT.]
AT END OF comp1.
ENDAT.]
[AT LAST.
ENDAT.]
ENDLOOP.
Extras:
1. ... FIRST
2. ... |{END OF} compi
3. ... LAST
Effect
The statement block of a LOOP loop can contain control structures for control level processing. The respective control statement is AT. The statements AT and ENDAT define statement blocks that are executed at control breaks, that is, when the control structure is changed. The additions to the AT statements determine the control break at which their statement blocks are executed. Within these statement blocks, the statement SUM can be specified to add together the numeric components of a control level. For the output behavior result, the same applies as for LOOP AT.
The prerequisite for control level processing is that the internal table is sorted in exactly the same sequence as the component of its line type - that is, first in accordance with the first component, then in accordance with the second component, and so on. The line structure and the corresponding sorting sequence gives a group structure of the content of the internal table, whose levels can be evaluated using AT statements. The AT- ENDAT control structures must be aligned one after the other, in accordance with the group structure.
The statement blocks within the AT- ENDAT control structures are listed if an appropriate control break is made in the current table line. Statements in the LOOP- ENDLOOP control structure that are not executed within an AT- ENDAT control structure are executed in each pass of the loop.
In order that control level processing is carried out properly, the following rules must be observed:
After LOOP, a restricting condition cond can only be specified if this selects a consecutive line block of the internal table. Otherwise, the behavior of control level processing is undefined.
The internal table cannot be modified within the LOOP loop.
A work area wa specified in the LOOP statement after the addition INTO must be compatible with the line type of the table.
The content of a work area wa specified after the addition INTO in the LOOP statement must not be modified.
If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:
The components of the current control key remain unchanged.
All components with a character-type, flat data type to the right of the current control key are set to character "*" in every position.
All the other components to the right of the current control key are set to their initial value.
When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa.
Addition 1
... FIRST
Effect
The control level is defined by the first line of the internal table. The control break takes place when this line is read.
Note
In the group level AT FIRST, the current group key contains no components and all character-type components of the work area wa are filled with "*" and all remaining components are set to their initial value.
Addition 2
... |{END OF} compi/>
Effect
: Control levels are defined by the beginning or end of a group of lines with the same content in the component compi (where i = 1, 2, and so on) and in the components to the left of compi. The control breaks take place when the content of the component compi or another component to the left of compi changes.
The compi components can be specified as described in Specification of Components, with the limitation that access to object attributes is not possible here.
Note
If the INTO or ASSIGNING additions are used in the LOOP statement, a field symbol can be entered after AT |{END OF} outside classes, to which the corresponding component of the work area wa or the field symbol <fs> is assigned. This form of dynamic component specification is obsolete and has been replaced by specification in the format (name).
Addition 3
... LAST
Effect
: The control level is defined by the last line of the internal table. The control break takes place when this line is read.
Note
In the group level AT LAST, the current group key contains no components and all character-type components of the work area wa are filled with "*" and all remaining components are set to their initial value.
Regards,
Prashant -
Problem using AT..NEW statement
I have a internal table with structure
posting_date amount
20090317 1500000
20090317 -950000
20090317 5000
20090319 8700
20090327 400000
20090327 32000
I am using AT NEW POSTING_DATE to perform some operation on the amount.
loop at itab.
AT NEW POSTING_DATE
LOGIC
ENDAT.
endloop.
all the record are working fine for AT NEW except for the last record.( posting date 20090327) It does not enter into AT..ENDAT
and simply goes to the endloop..Probably the reason for this is in AT new the current posting date is compared with the one that is above it...and if they are different AT NEW gets triggered. But in my case both the second last and last posting_date are the same, that's why AT NEW is not getting triggered..Please tell me how to solve this problem, how can I do the processing of last record?
PS this problem does not occur if both second last record and last record are different.
Edited by: priyasingh on Jul 22, 2009 11:01 AMHi,
AT NEW gets triggered here (in place where tested value has changed)
20090317 1500000 "<- here
20090317 -950000
20090317 5000
20090319 8700 "<- here
20090327 400000 "<- here
20090327 32000
If you want to get last value, use AT END OF event which get triggered
20090317 1500000
20090317 -950000
20090317 5000 "<- here
20090319 8700 "<- here
20090327 400000
20090327 32000 "<-here
And in case you want totally last value, use AT LAST event
20090317 1500000
20090317 -950000
20090317 5000
20090319 8700
20090327 400000
20090327 32000 "<- only here
Regards
Marcin -
Using a Datagrid in a New State
Is it possible to put a datagrid in a new state? Everytime I
try I get a parser error in the code. I am trying to have the
datagrid pop onto the scren after a selection is made which is why
I am putting it into another state.
Thanks.
DaveI think this should work. Can you post simplified sample
code. -
How can I use an IF ELSE statement and the xdoxslt: get_variable together?
First of all, I'm a big fan of this forum and I just want to thank the community for helping make the BI Publisher world a better place.
I'm trying to populate a table with a years worth of data with the column=PRODUCT and row=month of DATE. Here's the catch, not all of the months will have data. So here's where my problem is, I'm not able to use an IF ELSE statement along with a XDOXSLT:GET_VARIABLE expression so that if there's no data for that month the default value will be 0.
Can someone help me find a solution to either one of the attempts below or a completely new method? Thanks!
BP4 = numeric month value using DATE (more code to pull only month from DATE not included here)
JAN1 = PRICE if data exists, else 0
1) I tried this and it didn't work:
<?if: xdoxslt:get_variable($_XDOCTX,'BP4'),01 then xdoxslt:set_variable($_XDOCTX, 'JAN1',PRICE) else xdoxslt:set_variable($_XDOCTX, 'JAN1',0) end if?>
<?xdoxslt:get_variable($_XDOCTX,'JAN1')?>
<?end if?>
2) I tried this and it didn't work:
<?xdoxslt:ifelse(xdoxslt:get_variable($_XDOCTX,'BP4')='01',xdoxslt:set_variable($_XDOCTX, 'JAN1',PRICE),xdoxslt:set_variable($_XDOCTX, 'JAN1',0))?>
<?xdoxslt:get_variable($_XDOCTX,'JAN1')?>
<?end if?>
3) I tried this and it didn't work:
<?xdofx:if xdoxslt:get_variable($_XDOCTX,'BP4')='01' then xdoxslt:set_variable($_XDOCTX, 'JAN1',PRICE) else xdoxslt:set_variable($_XDOCTX, 'JAN1',0) end if?>
<?xdoxslt:get_variable($_XDOCTX,'JAN1')?>
<?end if?>
sample XML:
<ROW>
<Name>Craig Hernandez</NAME>
<DATE>2013-01-01T00:00:00.000+08:00</DATE>
<PRICE>31</PRICE>
<PRODUCT>BPD</PRODUCT>
</ROW>
-DrT
Edited by: 990965 on Feb 28, 2013 8:27 AMlet me clarify my logic, the template 1) searches for the relevant PRODUCT (in the case below, it searches for BPD which is the column in the table) 2) searches for the relevant month in DATE (which is the row in the table) 3) if data exists, get PRICE else default to 0
Variable definitions:
BP4 = numeric month value from DATE (more code to get this value not included here, but it works...)
JAN1 = set to PRICE if data exists for that month, else 0
the query is only pulling all of the existing data, so if there's no data for March then there wouldn't be a March entry in the xml. In the sample xml below, we only have data for the first two months (Jan, Feb) so that's the only data in the xml. I can't check if PRICE is null because the xml will not have any data for March.
I've read through other threads and it seems that BI Publisher can't use an IF THEN ELSE with the XDOXSLT:GET_VARIABLE. I sent the template and xml to you.
Sample XML:
<ROW>
<Name>Craig Hernandez</NAME>
<DATE>2013-01-01T00:00:00.000+08:00</DATE>
<PRICE>31</PRICE>
<PRODUCT>BPD</PRODUCT>
</ROW>
<ROW>
<Name>Craig Hernandez</NAME>
<DATE>2013-02-01T00:00:00.000+08:00</DATE>
<PRICE>30</PRICE>
<PRODUCT>BPD</PRODUCT>
</ROW>
Edited by: 990965 on Feb 28, 2013 8:30 AM -
I've been assigned to make some modification to an incomplete program written by another ABAPer. I have managed to fulfill most of what is required by the specification document, however, i'm having difficulty with a particular AT NEW statement that will WRITE a new PR Doc Type whenever the next line of output belongs to a different PR Doc Type than the previous line.
Currently, the PR Doc Type is always being written at each new line, no matter whether the current like is the same or different from the previous line's PR Doc Type.
Could you guys have a look what i have done so far?
NOTE: The original coding that i removed from the program were not deleted, i just * it
REPORT ZRMME006 NO STANDARD PAGE HEADING
MESSAGE-ID 38
LINE-SIZE 255
LINE-COUNT 65.
TABLES: EBAN, "Purchase Requisition
EBKN, "Purchase Requisition Account Assignment
EKKO, "Purchasing Document Header
EKPO, "Purchasing Document Item
EKBE, "History of Purchasing Document
EKET, "Scheduling Agreement Delivery Schedules
CDPOS, "Change document items
CDHDR, "Change document header
PRPS, "WBS (Work Breakdown Structure) Element Master Data
T161T. "Text for Purchasing Document Types
* DATA DECLARATION
DATA: BEGIN OF T_PR OCCURS 0,
KNTTP LIKE EBAN-KNTTP, "Account assignment category
KOSTL LIKE EBKN-KOSTL, "Cost center
POSID LIKE PRPS-POSID, "Project code name
PS_PSP_PNR LIKE EBKN-PS_PSP_PNR, "WBS element
ERNAM LIKE EBAN-ERNAM, "User ID
BANFN LIKE EBAN-BANFN, "PR number
BNFPO LIKE EBAN-BNFPO, "PR item number
MATNR LIKE EBAN-MATNR, "Material number
TXZ01 LIKE EBAN-TXZ01, "Material description
BSART LIKE EBAN-BSART, "PR document type
BATXT LIKE T161T-BATXT, "Desc of purchasing doc type
EBELN LIKE EBAN-EBELN, "PO number - eban
EKKO_EBELN LIKE EKKO-EBELN, "PO number - ekko
EKET_EBELN LIKE EKET-EBELN, "PO number - eket
EBELP LIKE EBAN-EBELP, "PO item number - eban
EKPO_EBELP LIKE EKPO-EBELP, "PO item number - ekpo
EKET_EBELP LIKE EKET-EBELP, "PO item number - eket
BADAT LIKE EBAN-BADAT, "PR creation date
CHANGENR_PR LIKE CDPOS-CHANGENR, "PR changenr
UDATE_PR LIKE CDHDR-UDATE, "PR approval date
ANFNR LIKE EKPO-ANFNR, "RFQ number
ANFPS LIKE EKPO-ANFPS, "RFQ item number
CHANGENR_RFQ LIKE CDPOS-CHANGENR, "RFQ changenr
UDATE_RFQ LIKE CDHDR-UDATE, "RFQ maintained date
AEDAT LIKE EKPO-AEDAT, "PO creation date
EINDT LIKE EKET-EINDT, "PO required (dev date)
CHANGENR_PO LIKE CDPOS-CHANGENR, "PO changenr
UDATE_PO LIKE CDHDR-UDATE, "PO approval date
DATVR_PO LIKE NAST-DATVR, "PO printed date
CPUDT LIKE EKBE-CPUDT, "GRN delivered date
FRGZU LIKE EBAN-FRGZU, "Release status
EKKO_FRGZU LIKE EKKO-FRGZU, "Release status
RFQ_AEDAT LIKE EKPO-AEDAT, "RFQ creation date
VSTAT LIKE NAST-VSTAT, "Processing status of message
EKGRP LIKE EBAN-EKGRP, "Purchasing group
END OF T_PR.
DATA: BEGIN OF T_DATE OCCURS 0,
CPUDT LIKE EKBE-CPUDT,
EBELN LIKE EKKO-EBELN,
EBELP LIKE EKPO-EBELP,
END OF T_DATE.
DATA: BEGIN OF T_PUR OCCURS 0.
INCLUDE STRUCTURE T_PR.
DATA: END OF T_PUR.
DATA: V_PRDAY(10) TYPE C, "PR days
V_RFQDAY(10) TYPE C, "RFQ days
V_PODAY(10) TYPE C, "PO days
V_GRNDAY(10) TYPE C, "GRN days
V_STADAY TYPE I, "Standard days
V_ACTDAY TYPE I, "Actual days
V_VARDAY(10) TYPE C, "Variance
V_RELPR TYPE I, "Release pr days
V_RELPO TYPE I, "Release po days
V_PRTEMP(10),
V_RFQTEMP(10),
V_POTEMP(10),
V_GRNTEMP(10),
V_FLAG(1) TYPE C,
V_FLAG2(1) TYPE C,
V_FLAG3(1) TYPE C,
V_COUNT TYPE I,
V_COUNT_MOD TYPE I,
V_SDATE LIKE SY-DATUM,
V_EDATE LIKE SY-DATUM,
V_LEN TYPE I,
V_LEN2 TYPE I.
DATA: CHECK(1) TYPE C. "DEVK951017
* selection screen *
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR EBAN-WERKS DEFAULT '6001' to '6002', "Plant
S_EKORG FOR EBAN-EKORG DEFAULT '6001' NO INTERVALS,
"Purch Org
S_BSART FOR EBAN-BSART,
"PR type
S_BANFN FOR EBAN-BANFN,
"PR number
S_BADAT FOR EBAN-BADAT.
"PR date
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: S_KOSTL FOR EBKN-KOSTL, "Cost ctr
S_PS_PNR FOR EBKN-PS_PSP_PNR NO-DISPLAY, "Project code
S_ERNAM FOR EBAN-ERNAM. "User ID
PARAMETERS: P_ASSET AS CHECKBOX DEFAULT 'X', "Acct Assign - A
P_KOSTL AS CHECKBOX DEFAULT 'X', "Acct Assign - K
P_ERNAM AS CHECKBOX DEFAULT 'X', "Acct Assign - Z
P_BSI AS CHECKBOX DEFAULT 'X', "Acct Assign - H
P_MOI AS CHECKBOX DEFAULT 'X', "Acct Assign - F
P_STA AS CHECKBOX DEFAULT 'X'. "Acct Assign - <blank>
SELECTION-SCREEN END OF BLOCK BLK2.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-003.
PARAMETERS: P_CON RADIOBUTTON GROUP PGRP, "Overseas
P_LCL RADIOBUTTON GROUP PGRP, "Local
P_ALL RADIOBUTTON GROUP PGRP DEFAULT 'X'. "All
SELECTION-SCREEN END OF BLOCK BLK3.
*--> range of knttp that the report will only select
RANGES: S_KNTTP FOR EBAN-KNTTP,
*--> range of tcode that approval obtained from
S_TCODE FOR CDHDR-TCODE.
TOP-OF-PAGE.
* perform write_rpttop using sy-title v_sdate v_edate. "DEVK951017
*PERFORM WRITE_RPTTOP USING SY-TITLE S_BADAT-LOW S_BADAT-
*HIGH."DEVK951017
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM INITIALISATION.
IF P_ASSET IS INITIAL AND
P_KOSTL IS INITIAL AND
P_ERNAM IS INITIAL AND
P_BSI IS INITIAL AND
P_MOI IS INITIAL AND
P_STA IS INITIAL.
MESSAGE S000 WITH TEXT-E02.
EXIT.
ELSE.
PERFORM SELECT_DATA.
IF V_FLAG NE 'X'.
PERFORM WRITE_REPORT.
* PERFORM GET_TPAGENO.
* PERFORM WRITE_RPTEND.
ELSE.
MESSAGE S000 WITH TEXT-E01.
ENDIF.
ENDIF.
*& Form SELECT_DATA
FORM SELECT_DATA.
IF P_CON EQ 'X'.
SELECT X~KNTTP Y~KOSTL X~ERNAM X~BANFN X~BNFPO X~MATNR
X~TXZ01 X~BSART X~EBELN X~EBELP X~BADAT X~FRGZU
FROM ( EBAN AS X
INNER JOIN EBKN AS Y
ON X~BANFN EQ Y~BANFN AND
X~BNFPO EQ Y~BNFPO )
APPENDING CORRESPONDING FIELDS OF TABLE T_PR
WHERE X~BANFN IN S_BANFN AND
X~LOEKZ EQ '' AND
X~KNTTP IN S_KNTTP AND
X~WERKS IN S_WERKS AND
X~BADAT IN S_BADAT AND
X~ERNAM IN S_ERNAM AND
X~BSART IN S_BSART AND
X~EKORG IN S_EKORG AND
Y~KOSTL IN S_KOSTL AND
EKGRP = 'OVS' AND
EKGRP = 'CON'.
ELSEIF P_LCL EQ 'X'.
SELECT X~KNTTP Y~KOSTL X~ERNAM X~BANFN X~BNFPO X~MATNR
X~TXZ01 X~BSART X~EBELN X~EBELP X~BADAT X~FRGZU
FROM ( EBAN AS X
INNER JOIN EBKN AS Y
ON X~BANFN EQ Y~BANFN AND
X~BNFPO EQ Y~BNFPO )
APPENDING CORRESPONDING FIELDS OF TABLE T_PR
WHERE X~BANFN IN S_BANFN AND
X~LOEKZ EQ '' AND
X~KNTTP IN S_KNTTP AND
X~WERKS IN S_WERKS AND
X~BADAT IN S_BADAT AND
X~ERNAM IN S_ERNAM AND
X~BSART IN S_BSART AND
X~EKORG IN S_EKORG AND
Y~KOSTL IN S_KOSTL AND
EKGRP = 'LCL'.
ELSE.
SELECT X~KNTTP Y~KOSTL X~ERNAM X~BANFN X~BNFPO X~MATNR
X~TXZ01 X~BSART X~EBELN X~EBELP X~BADAT X~FRGZU
FROM ( EBAN AS X
INNER JOIN EBKN AS Y
ON X~BANFN EQ Y~BANFN AND
X~BNFPO EQ Y~BNFPO )
APPENDING CORRESPONDING FIELDS OF TABLE T_PR
WHERE X~BANFN IN S_BANFN AND
X~LOEKZ EQ '' AND
X~KNTTP IN S_KNTTP AND
X~WERKS IN S_WERKS AND
X~BADAT IN S_BADAT AND
X~ERNAM IN S_ERNAM AND
X~BSART IN S_BSART AND
X~EKORG IN S_EKORG AND
Y~KOSTL IN S_KOSTL.
ENDIF.
* SELECT * FROM ZEPURDAY INTO T_PRDAY.
* APPEND T_PRDAY.
* ENDSELECT.
READ TABLE T_PR INDEX 1.
IF SY-SUBRC NE 0.
V_FLAG = 'X'.
ENDIF.
ENDFORM. " SELECT_DATA
*& Form WRITE_REPORT
FORM WRITE_REPORT.
DATA: V_ERNAM LIKE EBKN-ERNAM,
V_KOSTL LIKE EBKN-KOSTL.
*--> get from and to date for report header
PERFORM GET_TITLE_DATE.
*--> get header and line item data
PERFORM GET_HEADER_ITEM.
*--> check data entries of table zepurday.
* PERFORM CHECK_TZEPURDAY.
*--> identify sort key for sorting
PERFORM SORT.
CLEAR T_PUR.
LOOP AT T_PUR.
*--> get further data from tables against t_pr
PERFORM PROCESS_DATA.
*--> get standard day
PERFORM GET_STAND_DAY.
*--> get latest grn date
PERFORM GET_LATEST_GRNDATE.
*--> get actual day = GRN date - PR creation date
PERFORM GET_ACT_DAY.
*--> get variance days = Standard days - Actual days
PERFORM GET_VAR_DAY.
V_COUNT = V_COUNT + 1.
MOVE: T_PUR-ERNAM TO V_ERNAM,
T_PUR-KOSTL TO V_KOSTL.
AT NEW KNTTP.
IF V_FLAG3 NE 'X'.
* NEW-PAGE.
ENDIF.
V_FLAG3 = 'X'.
SKIP 1.
WRITE:/2 'Account Assignment:', 22(10) T_PUR-KNTTP COLOR COL_GROUP.
ENDAT.
*--> This is the part i am having trouble <--*
IF T_PUR-KNTTP EQ 'Z' OR
T_PUR-KNTTP EQ 'A' OR
T_PUR-KNTTP EQ 'K' OR
T_PUR-KNTTP EQ 'H' OR
T_PUR-KNTTP EQ 'F'.
AT NEW BSART.
SELECT SINGLE * FROM T161T
WHERE SPRAS = 'EN' AND
BSART = T_PUR-BSART AND
BSTYP = 'B'.
T_PUR-BATXT = T161T-BATXT.
IF V_FLAG3 NE 'X'.
ENDIF.
V_FLAG3 = 'X'.
WRITE:/2 'PR Doc Type Desc:',
22(3) T_PUR-BSART COLOR COL_GROUP.
WRITE: 26 T_PUR-BATXT NO-GAP COLOR COL_GROUP.
PERFORM WRITE_HEADER.
ENDAT.
ELSE.
AT NEW BSART.
SELECT SINGLE * FROM T161T
WHERE SPRAS = 'EN' AND
BSART = T_PUR-BSART AND
BSTYP = 'B'.
T_PUR-BATXT = T161T-BATXT.
IF V_FLAG3 NE 'X'.
ENDIF.
V_FLAG3 = 'X'.
WRITE:/2 'PR Doc Type Desc:',
22(3) T_PUR-BSART COLOR COL_GROUP.
WRITE: 26 T_PUR-BATXT NO-GAP COLOR COL_GROUP.
PERFORM WRITE_HEADER.
ENDAT.
ENDIF.
* IF T_PUR-KNTTP EQ 'Z'.
* AT NEW ERNAM.
* IF SY-LINNO >= 60.
* NEW-PAGE.
* ENDIF.
* WRITE:/2 'User ID:', 22(10) V_ERNAM COLOR COL_GROUP.
* PERFORM WRITE_HEADER. "write contents header
* ENDAT.
* ELSEIF T_PUR-KNTTP EQ 'A' OR T_PUR-KNTTP EQ 'K'.
* AT NEW KOSTL.
* IF SY-LINNO >= 60.
* NEW-PAGE.
* ENDIF.
* WRITE:/2 'Cost Center:', 22(10) V_KOSTL COLOR COL_GROUP.
* PERFORM WRITE_HEADER. "write contents header
* ENDAT.
* ELSEIF T_PUR-KNTTP EQ 'P'.
* AT NEW POSID.
* IF SY-LINNO >= 60.
* NEW-PAGE.
* ENDIF.
* WRITE:/2 'Project Code:', 22(10) T_PUR-POSID COLOR COL_GROUP.
* PERFORM WRITE_HEADER. "write contents header
* ENDAT.
* ENDIF.
*--> write report details
IF SY-LINNO >= 60.
ULINE (255).
NEW-PAGE.
PERFORM WRITE_HEADER.
ENDIF.
PERFORM INVERT_LINE_ITEMS_COLOR.
PERFORM WRITE_DETAILS.
*--> display data ordered by User ID/Cost Center/Project ID.
IF T_PUR-KNTTP EQ 'Z'.
AT END OF ERNAM.
ULINE (236).
SKIP 1.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
CLEAR: V_COUNT_MOD, V_COUNT.
ENDAT.
ELSEIF T_PUR-KNTTP EQ 'A' OR T_PUR-KNTTP EQ 'K'.
AT END OF KOSTL.
ULINE (236).
SKIP 1.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
CLEAR: V_COUNT_MOD, V_COUNT.
ENDAT.
ELSEIF T_PUR-KNTTP EQ 'H'.
AT END OF KOSTL.
ULINE (236).
SKIP 1.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
CLEAR: V_COUNT_MOD, V_COUNT.
ENDAT.
ELSEIF T_PUR-KNTTP EQ 'F'.
AT END OF KOSTL.
ULINE (236).
SKIP 1.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
CLEAR: V_COUNT_MOD, V_COUNT.
ENDAT.
ELSEIF T_PUR-KNTTP EQ ' '.
AT END OF KOSTL.
ULINE (236).
SKIP 1.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
CLEAR: V_COUNT_MOD, V_COUNT.
ENDAT.
ENDIF.
CLEAR: V_PRDAY,
V_PRTEMP,
V_RFQDAY,
V_RFQTEMP,
V_PODAY,
V_POTEMP,
V_GRNDAY,
V_GRNTEMP,
V_ACTDAY,
V_STADAY,
V_RELPR,
V_RELPO,
V_FLAG3.
ENDLOOP.
ENDFORM. " WRITE_REPORT
*& FORM INITIALISATION
*& Initialize value for s_knttp *
FORM INITIALISATION.
S_KNTTP-SIGN = 'I'.
S_KNTTP-OPTION = 'EQ'.
*--> BUDGETED ASSET
IF P_ASSET = 'X'.
S_KNTTP-LOW = 'A'.
APPEND S_KNTTP.
ENDIF.
*--> COST CENTER
IF P_KOSTL = 'X'.
S_KNTTP-LOW = 'K'.
APPEND S_KNTTP.
ENDIF.
*--> Project
*IF P_PCODE = 'X'.
* S_KNTTP-LOW = 'P'.
* APPEND S_KNTTP.f
*ENDIF.
*--> NON-BUDGETED ASSET
IF P_ERNAM = 'X'.
S_KNTTP-LOW = 'Z'.
APPEND S_KNTTP.
ENDIF.
*--> BALANCE SHEET ITEM
IF P_BSI = 'X'.
S_KNTTP-LOW = 'H'.
APPEND S_KNTTP.
ENDIF.
*--> MO ITEM
IF P_MOI = 'X'.
S_KNTTP-LOW = 'F'.
APPEND S_KNTTP.
ENDIF.
*--> STANDARD
IF P_STA = 'X'.
S_KNTTP-LOW = ' '.
APPEND S_KNTTP.
ENDIF.
S_TCODE-SIGN = 'I'.
S_TCODE-OPTION = 'EQ'.
S_TCODE-LOW = 'ZME55'.
APPEND S_TCODE.
S_TCODE-LOW = 'ME54'.
APPEND S_TCODE.
S_TCODE-LOW = 'ME28'.
APPEND S_TCODE.
S_TCODE-LOW = 'ME47'.
APPEND S_TCODE.
ENDFORM.
*& FORM SORT
FORM SORT.
CLEAR T_PUR.
LOOP AT T_PUR.
IF T_PUR-KNTTP EQ 'A' OR
T_PUR-KNTTP EQ 'K' OR
T_PUR-KNTTP EQ 'Z' OR
T_PUR-KNTTP EQ 'H' OR
T_PUR-KNTTP EQ 'F' OR
T_PUR-KNTTP EQ ' '.
SORT T_PUR BY BSART EBELN EBELP.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*& FORM PROCESS_DATA
FORM PROCESS_DATA.
DATA: V_TABKEY LIKE CDPOS-TABKEY,
V_TABKEY2 LIKE CDPOS-TABKEY,
V_TABKEY3 LIKE CDPOS-TABKEY.
CONCATENATE SY-MANDT T_PUR-BANFN T_PUR-BNFPO INTO V_TABKEY.
CONCATENATE SY-MANDT T_PUR-EBELN INTO V_TABKEY2.
CONCATENATE SY-MANDT T_PUR-ANFNR T_PUR-EKPO_EBELP INTO V_TABKEY3.
*--> get po history data
REFRESH T_DATE.
SELECT CPUDT EBELN EBELP
INTO CORRESPONDING FIELDS OF T_DATE
FROM EKBE
WHERE EBELN EQ T_PUR-EBELN AND EBELP EQ T_PUR-EBELP
AND BEWTP EQ 'E' AND BWART EQ '101'.
APPEND T_DATE.
ENDSELECT.
*-->get scheduling agreement delivery schedules data
SELECT EINDT INTO T_PUR-EINDT FROM EKET
WHERE EBELN EQ T_PUR-EBELN AND EBELP EQ T_PUR-EBELP.
MODIFY T_PUR TRANSPORTING EINDT
WHERE EBELN EQ T_PUR-EBELN AND EBELP EQ T_PUR-EBELP.
ENDSELECT.
*--> PR approval date
SELECT CHANGENR INTO T_PUR-CHANGENR_PR
FROM CDPOS
WHERE OBJECTCLAS EQ 'BANF' AND OBJECTID EQ T_PUR-BANFN
AND TABNAME EQ 'EBAN' AND TABKEY EQ V_TABKEY
AND FNAME EQ 'FRGKZ' AND CHNGIND EQ 'U'
AND VALUE_NEW EQ '2'.
MODIFY T_PUR TRANSPORTING CHANGENR_PR WHERE BANFN EQ T_PUR-BANFN.
ENDSELECT.
SELECT UDATE INTO T_PUR-UDATE_PR
FROM CDHDR
WHERE OBJECTCLAS EQ 'BANF' AND OBJECTID EQ T_PUR-BANFN
AND TCODE IN S_TCODE AND CHANGE_IND EQ 'U'
AND CHANGENR EQ T_PUR-CHANGENR_PR.
MODIFY T_PUR TRANSPORTING UDATE_PR WHERE BANFN EQ T_PUR-BANFN.
ENDSELECT.
*--> PO approval date
SELECT CHANGENR INTO T_PUR-CHANGENR_PO
FROM CDPOS
WHERE OBJECTCLAS EQ 'EINKBELEG' AND OBJECTID EQ T_PUR-EBELN
AND TABNAME EQ 'EKKO' AND TABKEY EQ V_TABKEY2
AND FNAME EQ 'FRGKE' AND CHNGIND EQ 'U'
AND VALUE_NEW EQ 'A'.
MODIFY T_PUR TRANSPORTING CHANGENR_PO WHERE EBELN EQ T_PUR-EBELN.
ENDSELECT.
SELECT UDATE INTO T_PUR-UDATE_PO
FROM CDHDR
WHERE OBJECTCLAS EQ 'EINKBELEG' AND OBJECTID EQ T_PUR-EBELN
AND TCODE IN S_TCODE AND CHANGE_IND EQ 'U'
AND CHANGENR EQ T_PUR-CHANGENR_PO.
MODIFY T_PUR TRANSPORTING UDATE_PO WHERE EBELN EQ T_PUR-EBELN.
ENDSELECT.
*--> PO printed date
SELECT DATVR VSTAT INTO (T_PUR-DATVR_PO, T_PUR-VSTAT)
FROM NAST
WHERE KAPPL EQ 'EF' AND OBJKY EQ T_PUR-EBELN.
* and vstat eq '1'.
MODIFY T_PUR TRANSPORTING DATVR_PO VSTAT
WHERE EBELN EQ T_PUR-EBELN.
ENDSELECT.
*--> RFQ maintained date
IF NOT T_PUR-ANFNR IS INITIAL.
SELECT CHANGENR INTO T_PUR-CHANGENR_RFQ
FROM CDPOS
WHERE OBJECTCLAS EQ 'EINKBELEG' AND OBJECTID EQ T_PUR-ANFNR
AND TABNAME EQ 'EKPO' AND TABKEY EQ V_TABKEY3
AND FNAME EQ 'NETPR' AND CHNGIND EQ 'U'.
MODIFY T_PUR TRANSPORTING CHANGENR_RFQ WHERE ANFNR EQ T_PUR-ANFNR.
ENDSELECT.
SELECT UDATE INTO T_PUR-UDATE_RFQ
FROM CDHDR
WHERE OBJECTCLAS EQ 'EINKBELEG' AND OBJECTID EQ T_PUR-ANFNR
AND TCODE IN S_TCODE AND CHANGE_IND EQ 'U'
AND CHANGENR EQ T_PUR-CHANGENR_RFQ.
MODIFY T_PUR TRANSPORTING UDATE_RFQ WHERE ANFNR EQ T_PUR-ANFNR.
ENDSELECT.
ELSE.
T_PUR-UDATE_RFQ = '00000000'.
ENDIF.
*--> get RFQ creation date
SELECT AEDAT INTO T_PUR-RFQ_AEDAT FROM EKPO
WHERE EBELN EQ T_PUR-ANFNR.
MODIFY T_PUR TRANSPORTING RFQ_AEDAT.
ENDSELECT.
*--> PR Days = PR release date - PR creation date
IF T_PUR-UDATE_PR IS INITIAL OR T_PUR-BADAT IS INITIAL.
V_PRDAY = '0'.
ELSE.
* v_prday = t_pur-udate_pr - t_pur-badat.
* v_prtemp = t_pur-udate_pr - t_pur-badat. " DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-BADAT T_PUR-UDATE_PR V_PRTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_PRTEMP
CHANGING V_PRDAY.
ENDIF.
*--> RFQ Days = RFQ quotation date - PR release date
* if t_pur-rfq_aedat is initial or t_pur-udate_pr is initial."DEVK951017
IF T_PUR-UDATE_RFQ IS INITIAL OR T_PUR-UDATE_PR IS INITIAL."DEVK951017
V_RFQDAY = '0'.
ELSE.
* v_rfqday = t_pur-rfq_aedat - t_pur-udate_pr.
* v_rfqtemp = t_pur-rfq_aedat - t_pur-udate_pr. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-UDATE_PR T_PUR-UDATE_RFQ V_RFQTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_RFQTEMP
CHANGING V_RFQDAY.
ENDIF.
*--> PO days
*--> RFQ number not exist (PO Days = PO printed date - PR released date)
IF T_PUR-ANFNR IS INITIAL.
* if t_pur-datvr_po is initial or t_pur-udate_pr is initial.
* v_poday = '0'.u
* else.
IF T_PUR-VSTAT = 1.
IF T_PUR-DATVR_PO IS INITIAL OR T_PUR-UDATE_PR IS INITIAL.
V_PODAY = '0'.
ELSE.
* v_poday = t_pur-datvr_po - t_pur-udate_pr.
* v_potemp = t_pur-datvr_po - t_pur-udate_pr. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-UDATE_PR T_PUR-DATVR_PO V_POTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_POTEMP
CHANGING V_PODAY.
ENDIF.
ELSEIF T_PUR-VSTAT = 2 OR T_PUR-VSTAT = 0.
IF T_PUR-AEDAT IS INITIAL OR T_PUR-UDATE_PR IS INITIAL.
V_PODAY = '0'.
ELSE.
* v_poday = t_pur-aedat - t_pur-udate_pr.
* v_potemp = t_pur-aedat - t_pur-udate_pr. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-UDATE_PR T_PUR-AEDAT V_POTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_POTEMP
CHANGING V_PODAY.
ENDIF.
ELSEIF T_PUR-VSTAT IS INITIAL.
V_PODAY = '0'.
ENDIF.
* endif.
ELSE.
*--> RFQ number exist (PO Days = PO printed date - Quotation date)
* if t_pur-datvr_po is initial or t_pur-rfq_aedat is initial.
* v_poday = '0'.
* else.
IF T_PUR-VSTAT = 1.
IF T_PUR-DATVR_PO IS INITIAL OR T_PUR-RFQ_AEDAT IS INITIAL.
V_PODAY = '0'.
ELSE.
* v_poday = t_pur-datvr_po - t_pur-rfq_aedat.
* v_potemp = t_pur-datvr_po - t_pur-rfq_aedat. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-RFQ_AEDAT T_PUR-DATVR_PO V_POTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_POTEMP
CHANGING V_PODAY.
ENDIF.
ELSEIF T_PUR-VSTAT = 2 OR T_PUR-VSTAT = 0.
IF T_PUR-AEDAT IS INITIAL OR T_PUR-RFQ_AEDAT IS INITIAL.
V_PODAY = '0'.
ELSE.
* v_poday = t_pur-aedat - t_pur-rfq_aedat.
* v_potemp = t_pur-aedat - t_pur-rfq_aedat. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-RFQ_AEDAT T_PUR-AEDAT V_POTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_POTEMP
CHANGING V_PODAY.
ENDIF.
ELSEIF T_PUR-VSTAT IS INITIAL.
V_PODAY = '0'.
ENDIF.
ENDIF.
CLEAR: V_TABKEY,
V_TABKEY2,
V_TABKEY3.
ENDFORM.
*& FORM WRITE_HEADER
FORM WRITE_HEADER.
ULINE (255).
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/ '|', 9 'PR',
21 '|', 48 'Material',
83 '|', 92 'PO',
103 '|', 107 'Purchase Requisition',
131 '|', 143 'RFQ',
159 '|', 176 'Purchase Order',
209 '|', 210 'S',
211 '|', 217 'GRN',
228 '|', 229 'Standard',
237 '|', 238 'Actual',
244 '|', 255 '|'.
ULINE (228).
FORMAT COLOR OFF.
WRITE: 237 '|', 244 '|', 255 '|'.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/ '|', 2 'Number',
12 '|', 13 'Item No.',
21 '|', 22 'Number',
41 '|', 42 'Description',
83 '|', 84 'Number',
94 '|', 95 'Item No.',
103 '|', 104 'Created',
114 '|', 115 'Released',
125 '|', 126 'Days',
131 '|', 132 'Created',
142 '|', 143 'Maintained',
153 '|', 154 'Days',
159 '|', 160 'Created',
170 '|', 171 'Required',
181 '|', 182 'Approved',
192 '|', 193 'Printed',
203 '|', 204 'Days',
209 '|',
211 '|', 212 'Delivered',
222 '|', 223 'Days',
228 '|', 229 'Days',
237 '|', 238 'Days',
244 '|', 245 'Variance',
255 '|'.
FORMAT COLOR OFF.
ULINE (255).
ENDFORM. " WRITE_HEADER
*& Form INVERT_LINE_ITEMS_COLOR
FORM INVERT_LINE_ITEMS_COLOR.
V_COUNT_MOD = V_COUNT MOD 2.
IF V_COUNT_MOD EQ '0'.
FORMAT COLOR COL_KEY INTENSIFIED OFF.
ELSE.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
ENDIF.
ENDFORM. " INVERT_LINE_ITEMS_COLOR
*& Form GET_TITLE_DATE
FORM GET_TITLE_DATE.
IF NOT S_BADAT-LOW IS INITIAL AND NOT S_BADAT-HIGH IS INITIAL.
V_SDATE = S_BADAT-LOW.
V_EDATE = S_BADAT-HIGH.
ELSE.
SORT T_PR BY BADAT ASCENDING.
READ TABLE T_PR INDEX 1.
V_SDATE = T_PR-BADAT.
SORT T_PR BY BADAT DESCENDING.
READ TABLE T_PR INDEX 1.
V_EDATE = T_PR-BADAT.
ENDIF.
ENDFORM. " GET_TITLE_DATE
*& Form GET_LATEST_GRNDATE
FORM GET_LATEST_GRNDATE.
DATA: D_LINES TYPE I.
CLEAR T_DATE.
DESCRIBE TABLE T_DATE LINES D_LINES.
IF D_LINES GT 0.
SORT T_DATE BY CPUDT EBELN EBELP DESCENDING.
READ TABLE T_DATE WITH KEY EBELN = T_PUR-EBELN.
IF SY-SUBRC = 0.
READ TABLE T_DATE INDEX 1.
MOVE: T_DATE-CPUDT TO T_PUR-CPUDT.
MODIFY T_PUR TRANSPORTING CPUDT
WHERE EBELN = T_PUR-EBELN AND EBELP = T_PUR-EBELP.
ENDIF.
ENDIF.
*--> GRN Days = GRN date - PO printed date
IF T_PUR-VSTAT = 1.
IF T_PUR-CPUDT IS INITIAL OR T_PUR-DATVR_PO IS INITIAL.
V_GRNDAY = '0'.
ELSE.
* v_grnday = t_pur-cpudt - t_pur-datvr_po.
* v_grntemp = t_pur-cpudt - t_pur-datvr_po. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-DATVR_PO T_PUR-CPUDT V_GRNTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_GRNTEMP
CHANGING V_GRNDAY.
ENDIF.
ELSEIF T_PUR-VSTAT = 2 OR T_PUR-VSTAT = 0.
IF T_PUR-CPUDT IS INITIAL OR T_PUR-AEDAT IS INITIAL.
V_GRNDAY = '0'.
ELSE.
* v_grnday = t_pur-cpudt - t_pur-datvr_po.
* v_grntemp = t_pur-cpudt - v_grntemp. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-AEDAT T_PUR-CPUDT V_GRNTEMP. "DEVK951017
PERFORM CONVERT_NEG_TO_BRACKET USING V_GRNTEMP
CHANGING V_GRNDAY.
ENDIF.
ENDIF.
ENDFORM. " GET_LATEST_GRNDATE
*& Form GET_HEADER_ITEM
FORM GET_HEADER_ITEM.
DATA: V_OBJNR LIKE PRPS-OBJNR,
V_TEMP(4) TYPE C.
clear t_pr.
loop at t_pr.
SELECT EBELN EBELP FROM EKET
INTO (EKET-EBELN, EKET-EBELP)
WHERE BANFN EQ T_PR-BANFN AND BNFPO EQ T_PR-BNFPO.
SELECT EBELN FRGZU FROM EKKO
INTO (EKKO-EBELN, EKKO-FRGZU)
WHERE EBELN EQ EKET-EBELN.
SELECT EBELP ANFNR ANFPS AEDAT FROM EKPO
INTO (EKPO-EBELP, EKPO-ANFNR, EKPO-ANFPS, EKPO-AEDAT)
WHERE EBELN EQ EKET-EBELN AND EBELP EQ EKET-EBELP
AND BSTYP EQ 'F'.
MOVE-CORRESPONDING T_PR TO T_PUR.
MOVE: EKET-EBELN TO T_PUR-EKET_EBELN,
EKET-EBELP TO T_PUR-EKET_EBELP,
EKKO-EBELN TO T_PUR-EKKO_EBELN,
EKKO-FRGZU TO T_PUR-EKKO_FRGZU,
EKPO-EBELP TO T_PUR-EKPO_EBELP,
EKPO-ANFNR TO T_PUR-ANFNR,
EKPO-ANFPS TO T_PUR-ANFPS,
EKPO-AEDAT TO T_PUR-AEDAT.
V_FLAG2 = 'Y'.
APPEND T_PUR.
ENDSELECT.
ENDSELECT.
ENDSELECT.
IF V_FLAG2 NE 'Y'.
MOVE-CORRESPONDING T_PR TO T_PUR.
APPEND T_PUR.
ENDIF.
*--> get project code name
CONCATENATE 'PR' T_PR-PS_PSP_PNR INTO V_OBJNR.
SELECT SINGLE POSID INTO T_PR-POSID FROM PRPS WHERE OBJNR EQ V_OBJNR.
SPLIT T_PR-POSID AT '/' INTO T_PUR-POSID V_TEMP.
MODIFY T_PUR TRANSPORTING POSID WHERE PS_PSP_PNR EQ T_PR-PS_PSP_PNR.
CLEAR V_FLAG2.
ENDLOOP.
ENDFORM. " GET_HEADER_ITEM
*& Form WRITE_DETAILS
FORM WRITE_DETAILS.
WRITE:/ '|', 2 T_PUR-BANFN, "PR no
12 '|', 13 T_PUR-BNFPO, "item no
41 '|', 42 T_PUR-TXZ01, "mat description
103 '|', 104 T_PUR-BADAT, "PR creation date
125 '|', 126 V_PRDAY LEFT-JUSTIFIED, "PR days
131 '|',
153 '|', 154 V_RFQDAY LEFT-JUSTIFIED, "RFQ days
203 '|', 204 V_PODAY LEFT-JUSTIFIED, "PO days
209 '|', 210 T_PUR-VSTAT,
222 '|', 223 V_GRNDAY LEFT-JUSTIFIED, "GRN days
228 '|', 229 V_STADAY LEFT-JUSTIFIED, "Standard days
237 '|', 238 V_ACTDAY LEFT-JUSTIFIED, "Actual days
244 '|', 245 V_VARDAY LEFT-JUSTIFIED, "Variance days
255 '|'.
IF T_PUR-MATNR IS INITIAL.
WRITE: 21 '|', 22 '-'.
ELSE.
WRITE: 21 '|', 22 T_PUR-MATNR. "mat no
ENDIF.
IF T_PUR-EKKO_EBELN IS INITIAL.
WRITE: 83 '|', 84 '-'.
ELSE.
WRITE: 83 '|', 84 T_PUR-EKKO_EBELN. "PO number
ENDIF.
IF T_PUR-EKPO_EBELP EQ '00000' OR T_PUR-EKPO_EBELP IS INITIAL.
WRITE: 94 '|', 95 '-'.
ELSE.
WRITE: 94 '|', 95 T_PUR-EKPO_EBELP. "PO item no
ENDIF.
IF T_PUR-UDATE_PR EQ '00000000'.
WRITE: 114 '|', 115 '-'.
ELSE.
WRITE: 114 '|', 115 T_PUR-UDATE_PR. "PR released date
ENDIF.
IF T_PUR-RFQ_AEDAT EQ '00000000'.
WRITE: 132 '-', 142 '|'.
ELSE.
WRITE: 132 T_PUR-RFQ_AEDAT, 142 '|'. "RFQ creation date
ENDIF.
IF T_PUR-UDATE_RFQ EQ '00000000'.
WRITE: 143 '-'.
ELSE.
WRITE: 143 T_PUR-UDATE_RFQ. "RFQ maintained date
ENDIF.
IF T_PUR-AEDAT EQ '00000000'.
WRITE: 159 '|', 160 '-'.
ELSE.
WRITE: 159 '|', 160 T_PUR-AEDAT. "PO creation date
ENDIF.
IF T_PUR-EINDT EQ '00000000'.
WRITE: 170 '|', 171 '-'.
ELSE.
WRITE: 170 '|', 171 T_PUR-EINDT. "PO required date
ENDIF.
IF T_PUR-UDATE_PO EQ '00000000'.
WRITE: 181 '|', 182 '-'.
ELSE.
WRITE: 181 '|', 182 T_PUR-UDATE_PO. "PO released date
ENDIF.
IF T_PUR-VSTAT = 1.
* if t_pur-datvr_po eq '00000000'.
* write: 192 '|', 193 '-'.
* else.
WRITE: 192 '|', 193 T_PUR-DATVR_PO. "PO printed date
* endif.
* elseif t_pur-vstat = 2 or t_pur-vstat = 0. "DEVK951017
ELSEIF T_PUR-VSTAT = 2. "DEVK951017
WRITE: 192 '|', 193 T_PUR-AEDAT. "PO creation date
ELSEIF T_PUR-VSTAT = 0. "DEVK951017
WRITE: 192 '|', 193 '-'. "PO printed date not shown "DEVK951017
ENDIF.
IF T_PUR-CPUDT EQ '00000000'.
WRITE: 211 '|', 212 '-'.
ELSE.
WRITE: 211 '|', 212 T_PUR-CPUDT. "GRN delivered date
ENDIF.
ENDFORM. " WRITE_DETAILS
*& Form CHECK_TZEPURDAY
FORM CHECK_TZEPURDAY.
* CLEAR T_PRDAY.
* READ TABLE T_PRDAY INDEX 1.
* IF SY-SUBRC NE 0.
* FORMAT COLOR COL_NEGATIVE ON.
* WRITE:/ '*** No Table Entries Found in Table ZEPURDAY ***'.
* FORMAT COLOR OFF.
* ENDIF.
ENDFORM. " CHECK_TZEPURDAY
*& Form GET_STAND_DAY
FORM GET_STAND_DAY.
*--> PR release days
* CLEAR T_PRDAY.
* READ TABLE T_PRDAY WITH KEY PR_TYPE = T_PUR-BSART.
* IF SY-SUBRC EQ 0.
* CLEAR V_LEN.
* CONDENSE T_PUR-FRGZU.
* V_LEN = STRLEN( T_PUR-FRGZU ).
* IF V_LEN EQ 0.
* V_RELPR = 0.
* ELSEIF V_LEN EQ '1'.
* V_RELPR = T_PRDAY-PR_RE1.
* ELSEIF V_LEN EQ '2'.
* V_RELPR = T_PRDAY-PR_RE1 + T_PRDAY-PR_RE2.
* ELSEIF V_LEN EQ '3'.
* V_RELPR = T_PRDAY-PR_RE1 + T_PRDAY-PR_RE2 + T_PRDAY-PR_RE3.
* ELSE.
* V_RELPR = T_PRDAY-PR_RE1 + T_PRDAY-PR_RE2 +
* T_PRDAY-PR_RE3 + T_PRDAY-PR_RE4.
* ENDIF.
*--> PO release days
* CLEAR V_LEN2.
* CONDENSE T_PUR-EKKO_FRGZU.
* V_LEN2 = STRLEN( T_PUR-EKKO_FRGZU ).
* IF V_LEN2 EQ 0.
* V_RELPO = 0.
* ELSEIF V_LEN2 EQ '1'.
* V_RELPO = T_PRDAY-PO_RE1.
* ELSEIF V_LEN2 EQ '2'.
* V_RELPO = T_PRDAY-PO_RE1 + T_PRDAY-PO_RE2.
* ELSEIF V_LEN2 EQ '3'.
* V_RELPO = T_PRDAY-PO_RE1 + T_PRDAY-PO_RE2 + T_PRDAY-PO_RE3.
* ELSE.
* V_RELPO = T_PRDAY-PO_RE1 + T_PRDAY-PO_RE2 +
* T_PRDAY-PO_RE3 + T_PRDAY-PO_RE4.
* ENDIF.
CHECK = ' '. "DEVK951017
IF NOT ( T_PUR-EKKO_EBELN IS INITIAL ) AND "DEVK951017
T_PUR-ANFNR IS INITIAL AND T_PUR-KNTTP = 'P'.
PERFORM CHECK_RFQ. "DEVK951017
** IF CHECK = 'X'.
** V_STADAY = T_PRDAY-PR_CRT + V_RELPR + T_PRDAY-PO_CRT +
*"DEVK951017
** V_RELPO + T_PRDAY-PO_PRN + T_PRDAY-GRN_CRT.
** ENDIF.
*ELSE.
**--> Standard Days
* V_STADAY = T_PRDAY-PR_CRT + V_RELPR + T_PRDAY-RFQ_CRT +
* T_PRDAY-RFQ_MAN + T_PRDAY-PO_CRT +
* V_RELPO + T_PRDAY-PO_PRN + T_PRDAY-GRN_CRT.
** + t_prday-pay_crt + t_prday-inv_crt.
"DEVK951017
*ENDIF.
ENDIF. "DEVK951017
ENDFORM. " GET_STAND_DAY
*& Form GET_ACT_DAY
FORM GET_ACT_DAY.
DATA: V_CPUDT LIKE SY-DATUM.
* IF T_PUR-CPUDT IS INITIAL OR T_PUR-BADAT IS INITIAL.
* V_ACTDAY = '0'.
* ELSE.
* V_ACTDAY = T_PUR-CPUDT - T_PUR-BADAT.
* ENDIF.
V_CPUDT = SY-DATUM.
IF T_PUR-CPUDT IS INITIAL.
* v_actday = v_cpudt - t_pur-badat. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-BADAT V_CPUDT V_ACTDAY.
ELSEIF T_PUR-BADAT IS INITIAL.
V_ACTDAY = '0'.
ELSE.
* v_actday = t_pur-cpudt - t_pur-badat. "DEVK951017
PERFORM CALC_ACT_WORKDAY "DEVK951017
USING T_PUR-BADAT T_PUR-CPUDT V_ACTDAY.
ENDIF.
ENDFORM. " GET_ACT_DAY
*& Form GET_VAR_DAY
FORM GET_VAR_DAY.
DATA: V_TEMP2(8).
V_TEMP2 = V_STADAY - V_ACTDAY.
PERFORM CONVERT_NEG_TO_BRACKET USING V_TEMP2
CHANGING V_VARDAY.
ENDFORM. " GET_VAR_DAY
*& Form CONVERT_NEG_TO_BRACKET
FORM CONVERT_NEG_TO_BRACKET USING P_V_TEMP
CHANGING P_V_DAY.
SEARCH P_V_TEMP FOR '-'.
IF SY-SUBRC = 0.
SHIFT P_V_TEMP RIGHT BY 1 PLACES.
SHIFT P_V_TEMP LEFT DELETING LEADING SPACE.
CONCATENATE '(' P_V_TEMP ')' INTO P_V_DAY.
ELSE.
SHIFT P_V_TEMP LEFT DELETING LEADING SPACE.
MOVE P_V_TEMP TO P_V_DAY.
ENDIF.
ENDFORM. " CONVERT_NEG_TO_BRACKET
*& Form CALC_ACT_WORKDAY -DEVK951017
* -->lowdt -Low Date *
* -->Highdt -High Date *
* -->days -Total Days *
FORM CALC_ACT_WORKDAY USING LOWDT HIGHDT DAYS.
DATA: DAT LIKE SY-DATUM.
DAYS = 0.
DAT = LOWDT.
DO.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
DATE = DAT
FACTORY_CALENDAR_ID = 'MY'
MESSAGE_TYPE = 'I'
EXCEPTIONS
DATE_AFTER_RANGE = 1
DATE_BEFORE_RANGE = 2
DATE_INVALID = 3
DATE_NO_WORKINGDAY = 4
FACTORY_CALENDAR_NOT_FOUND = 5
MESSAGE_TYPE_INVALID = 6
OTHERS = 7.
IF SY-SUBRC = 0.
DAYS = DAYS + 1.
ENDIF.
DAT = DAT + 1.
IF DAT GE HIGHDT.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " CALC_ACT_WORKDAY
*& Form CHECK_RFQ
* text
* --> p1 text
* <-- p2 text
FORM CHECK_RFQ.
DATA: KONNR LIKE EKPO-KONNR,
AEDAT LIKE EKKO-AEDAT.
SELECT SINGLE P~KONNR K~AEDAT INTO (KONNR, AEDAT)
FROM EKPO AS P INNER JOIN EKKO AS K
ON P~EBELN = K~EBELN WHERE P~EBELN = T_PUR-EKKO_EBELN
AND P~EBELP = T_PUR-EKPO_EBELP AND K~BSTYP = 'K'
AND P~KONNR = K~KONNR.
IF SY-SUBRC = 0.
IF AEDAT < T_PUR-BADAT.
CHECK = 'X'.
ENDIF.
ENDIF.
ENDFORM. " CHECK_RFQ
By the way, it's my first time trying to modify other people's codes, is there a proper way to do this. I find it more difficult to modify people's code than to write my own. Perhaps you guys could give me some advice, so i'll know what to do when i'm assigned to do it again next time?Even though you think AT NEW will work on just the field that you mentioned, it is not. Your field BSART is about 6th or 7th field in your internal table. So any change in any of the field values before BSART will trigger this AT NEW BSART code.
You have to declare your own variables to keep track of the current value of BSART and previous value of the same. Also, remember that it may not have been sorted by BSART. So your logic may not work and if you change the sort, then your previous AT NEW may not work. So be sure of what you want to do there.
Srinivas -
SOME FIELDS OF WORK AREA ARE CONVERTED TO ***** AT AT NEW STATEMENT
HELLO
SOME OF THE FIELDS OF WORK AREA ARE CONVERTED INTO *********** AT AT NEW STATEMENT .FIND BELOW THE CODE
*& Report YTEST_OBJECTS7
REPORT YTEST_OBJECTS7.
Program Description
Author.........: Jitendra Dash *
Creation date..: 17/09/2010 *
GAP ID/FS Id...: *
Transport......: *
Description u2026..: *
CHANGE HISTORY u2013 Should be completed in reverse date order *
Revised by........: <Developer name> *
Change date.......: Date of creation> *
CR/Defect No......: <Change Request No>/ <Defect#<xxx> *
Transport.........: <Request No> *
Description.......: Description about modification *
Data Declaration
TYPES: BEGIN OF gx_input,
NEMI TYPE EXT_UI,
DIVISION TYPE SPARTE ,
DATE TYPE ERDAT,
DATE1 TYPE ERDAT,
END OF gx_input.
TYPES: BEGIN OF gx_input1,
NEMI TYPE EXT_UI,
DIVISION TYPE SPARTE ,
DATE TYPE ERDAT,
DATE1 TYPE ERDAT,
int_ui TYPE INT_UI,
ANlage type anlage,
SERVICE TYPE SERCODE,
SERVICEID TYPE SERVICE_PROV,
SPARTE TYPE SPARTE,
END OF gx_input1.
TYPES : BEGIN OF gx_euitrans,
INT_UI TYPE INT_UI,
EXT_UI type EXT_UI,
END OF gx_euitrans.
TYPES : BEGIN OF gx_eservice,
INT_UI TYPE INT_UI,
SERVICE TYPE SERCODE,
SERVICEID TYPE SERVICE_PROV,
SPARTE TYPE SPARTE,
END OF gx_eservice.
TYPES : BEGIN OF gx_inst,
int_ui TYPE INT_UI,
ANlage type anlage,
END OF gx_inst.
TYPES : BEGIN OF gx_ever,
ANLAGE TYPE anlage,
EINZDAT TYPE EINZDAT,
AUSZDAT TYPE AUSZDAT,
VERTRAG type VERTRAG,
vkonto TYPE VKONT_KK,
END OF gx_ever .
TYPES : BEGIN OF gx_fkkvkp,
VKONT type VKONT_KK,
GPART type GPART_KK,
END OF gx_fkkvkp.
DATA : GIT_INPUT TYPE STANDARD TABLE OF GX_INPUT,
git_euitrans TYPE STANDARD TABLE OF gx_euitrans,
git_eservice TYPE STANDARD TABLE OF gx_eservice,
git_inst TYPE STANDARD TABLE OF gx_inst,
git_ever TYPE STANDARD TABLE OF gx_ever,
GIT_INPUT1 TYPE STANDARD TABLE OF GX_INPUT1,
GIT_fkkvkp TYPE STANDARD TABLE OF GX_fkkvkp,
WA_INPUT TYPE gx_input,
wa_euitrans LIKE LINE OF git_euitrans,
wa_eservice like LINE OF git_eservice,
WA_inst LIKE LINE OF git_inst,
wa_ever LIKE LINE OF git_ever,
wa_INPUT1 like LINE OF git_INPUT1,
wa_fkkvkp like LINE OF GIT_fkkvkp.
DATA: gv_v_localfile TYPE localfile,
gv_g_localfile type string,
gv_g_alocalfile type string,
gv_g_sender type SERVICE_PROV,
gv_g_reciever type SERVICE_PROV.
CONSTANTS : GC_AINP TYPE c LENGTH 50 VALUE '/tmp'.
************Selection screen for input *********************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.
PARAMETERS : p_rad1 RADIOBUTTON GROUP grp DEFAULT 'X' USER-COMMAND chk,
p_rad2 RADIOBUTTON GROUP grp,
p_file TYPE file_table-filename MODIF ID m1,
p_afile TYPE file_table-filename MODIF ID m2.
SELECTION-SCREEN END OF BLOCK b1.
***************Initialization*****************************
INITIALIZATION.
t1 = text-001.
***Selection of Appl ser and Presen ser for I/P file******
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF p_rad1 = 'X'.
IF screen-group1 = 'M2'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ELSEIF p_rad2 = 'X'.
IF screen-group1 = 'M1'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
**F4 help for inputting the Filename from presentation Ser*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = sy-repid
dynpro_number = sy-dynnr
field_name = p_file
CHANGING
file_name = gv_v_localfile
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc = 0.
MOVE gv_v_localfile TO p_file.
move gv_v_localfile to gv_g_localfile.
ENDIF.
***F4 help for file on Application Server*******************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_afile.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = GC_AINP
filemask = ' '
IMPORTING
serverfile = p_afile
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc = 0.
move p_afile to gv_g_alocalfile.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
START-OF-SELECTION.
IF p_rad1 = 'X'.
*************Upload file into Itab from pres server*********
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = gv_g_localfile
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '|'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = GIT_INPUT
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.
ELSEIF p_rad2 = 'X'.
*************Upload file into Itab from Applic server*********
************file should be ; seperated and not tab seper******
TRANSLATE gv_g_alocalfile USING '\/'.
OPEN DATASET gv_g_alocalfile FOR INPUT MESSAGE gv_LC_MESSAGE in TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET gv_g_alocalfile INTO wa_xls.
IF sy-subrc IS NOT INITIAL.
EXIT.
ELSE.
APPEND wa_xls TO git_xls.
ENDIF.
ENDDO.
ENDIF.
close DATASET gv_g_alocalfile.
ENDIF.
SELECT INT_UI EXT_UI from EUITRANS
into CORRESPONDING FIELDS OF TABLE git_euitrans
for ALL ENTRIES IN GIT_INPUT
WHERE ext_ui = GIT_INPUT-NEMI.
SElect INT_UI
SERVICE
SERVICEID
SPARTE from ESERVICE
into CORRESPONDING FIELDS OF TABLE git_eservice
FOR ALL ENTRIES IN git_euitrans
where INT_UI = git_euitrans-INT_UI .
SELECT INT_UI
ANLAGE from euiinstln
into CORRESPONDING FIELDS OF TABLE GIT_INST
FOR ALL ENTRIES IN git_eservice
WHERE INT_UI = git_eservice-INT_UI.
LOOP AT git_eservice into wa_eservice.
READ TABLE git_euitrans into wa_euitrans
with KEY int_ui = wa_eservice-int_ui.
IF SY-SUBRC = 0.
READ TABLE git_input into wa_input
WITH key NEMI = wa_euitrans-EXT_UI.
IF SY-SUBRC = 0.
READ TABLE GIT_INST into WA_INST
with key int_ui = wa_eservice-int_ui.
IF Sy-subrc = 0.
wa_input1-NEMI = wa_input-NEMI .
wa_input1-DIVISION = wa_input-DIVISION.
wa_input1-DATE = wa_input-DATE.
wa_input1-DATE1 = wa_input-DATE1.
wa_input1-int_ui = wa_eservice-int_ui.
wa_input1-anlage = WA_INST-anlage.
wa_input1-SERVICE = wa_eservice-service.
wa_input1-SERVICEID = wa_eservice-serviceid.
wa_input1-SPARTE = wa_eservice-sparte.
Append wa_input1 to git_input1.
ENDIF.
ENDIF.
ENDIF.
clear : wa_eservice,wa_input,WA_INST,wa_euitrans,wa_input1 .
ENDLOOP.
SELECT anlage
EINZDAT
AUSZDAT
VERTRAG
VKONTO from ever
into CORRESPONDING FIELDS OF TABLE git_ever
FOR ALL ENTRIES IN git_input1
WHERE anlage = git_input1-ANLAGE
and EINZDAT = git_input1-DATE
or AUSZDAT = git_input1-DATE1.
Select Vkont Gpart from fkkvkp
into CORRESPONDING FIELDS OF TABLE git_fkkvkp
for ALL ENTRIES IN git_ever
where Vkont = git_ever-Vkonto.
LOOP AT git_input1 INTO wa_input1 .
IF wa_input1-SPARTE = 01 .
CASE wa_input1-SERVICE.
WHEN 'FRMP'.
gv_g_sender = wa_input1-SERVICEID.
WHEN 'LNSP'.
gv_g_reciever = wa_input1-SERVICEID.
ENDCASE.
ELSEIF wa_input1-SPARTE = 02 .
CASE wa_input1-SERVICE.
WHEN 'FRO'.
gv_g_sender = wa_input1-SERVICEID.
WHEN 'DB'.
gv_g_reciever = wa_input1-SERVICEID.
ENDCASE.
ENDIF.
data : int_ui TYPE INT_UI.
*int_ui = wa_input1-int_ui .
AT NEW int_ui .
READ TABLE git_ever into wa_ever with key anlage = wa_input1-anlage.
READ TABLE git_fkkvkp INTO wa_fkkvkp with key Vkont = wa_ever-Vkonto.
CALL FUNCTION 'ZIN_COMEV_CUSTDETAILNOTIF_OUT'
EXPORTING
Y_SENDER = gv_g_sender
Y_RECEIVER = gv_g_reciever
Y_PARTNER = wa_fkkvkp-gpart
Y_BASIC_PROCESS = 'ZCDNO'
Y_SWITCHNUM =
Y_SEN_LOAD =
Y_INTUI = wa_input1-int_ui
Y_TRANSACTIONID =
Y_DATE = wa_input1-DATE
IMPORTING
X_TASK_ID =
TABLES
IDOC_STATUS =
IDOC_CONTRL =
XYT_ERROR =
EXCEPTIONS
GENERAL_FAULT = 1
NOT_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.
ENDAT.
ENDLOOP.
IN THIS PROGRAM AT AT NEW STATEMENT IN LOOP SOME OF THE FIELDS OF wa_input1 IS CONVERTED TO ***** E.G wa_input1-anlage.
pLEASE HELP ME OUTHELLO
My Q is some fields at AT NEW statement turns into *****.Please help me out
TYPES: BEGIN OF gx_input1,
NEMI TYPE EXT_UI,
DIVISION TYPE SPARTE ,
DATE TYPE ERDAT,
DATE1 TYPE ERDAT,
int_ui TYPE INT_UI,
ANlage type anlage,
SERVICE TYPE SERCODE,
SERVICEID TYPE SERVICE_PROV,
SPARTE TYPE SPARTE,
END OF gx_input1.
GIT_INPUT1 TYPE gx_input1.
LOOP AT git_input1 INTO wa_input1 .
AT NEW int_ui .----
>hERE FIELDS OF wa_input1 ARE TURNED INTO *
EX: wa_input1-ANLAGE =******** AFTER AT IN COMMAND.
END AT
eNDLOOP -
dear all,
My problem is that , in the following code
at new matnr.
write: itab-matnr, itab-maktx.
end at.
It is displaying matnr properly .. but for maktx its is showing '****' . Can anybody tell why this happens .. How to solve that ? I have given enough spaces for displaying maktx.. Still its showing ''. Why ?
please help me to solve my problem ..
Thanking you ..
ShankarHi Shankar,
This is a very common problem for most first-time users of the AT NEW statement. But there's a way to overcome the problem : use field-symbols.
Consider the following simple code-snippet which will solve your problem very efficiently.
========================================
data t_mara type table of mara.
field-symbols: <fs_mara> type mara.
select * from mara into table t_mara.
sort t_mara by matnr.
loop at t_mara assigning <fs_mara>.
at new matnr.
write: / <fs_mara>-matnr,
<fs_mara>-mtart,
<fs_mara>-matkl.
endat.
endloop.
========================================
Normally, you will not be able to use the fields MTART and MATKL within the AT NEW....ENDAT block. But as you can see here, if you use field-symbols, there's no problem at all. Moreover, though most people have some resistance to using field-symbols, it offers the best performance and the highest degree of flexibility.
Hope this solution can be satisfactorily applied in your case.
Regards,
Anand Mandalika.
P.S: FYI, when you use field symbols, the system does not have to transfer the contents of the current line into the work area. As the number of entries (as well as the record-length) in the internal table increases, this can sometimes become a major performance overhead. -
Hello experts,
I am currently having a problem with my At New statement. It is treating every field of the itab as a new record even though it is the same.
For example,
on the first loop the field matnr has a value of mat-A then the at new will trigger.
then on the second loop matnr has a value of mat-B then again, At New will trigger.that is correct.
But on the third loop, the field matnr will have a value again of mat-B or Mat-A- the same as that of the second or first loop. So it must not trigger the At New statement but it does.
Any solutions?
MY CODING.....
SORT IT_FINAL BY MATNR.
LOOP AT IT_FINAL.
wa_final = it_final.
at new matnr.
it_final1-matnr = wa_final-matnr.
it_final1-maktx = wa_final-maktx.
it_final1-bdmng = VAL1.
APPEND it_final1.
clear : it_final, it_final1, wa_final.
endat.
ENDLOOP.
Thanks!
REGARDS,
NAVANEETH.Hi navaneethan,
it is important to understand SAP's concept of Control Level Processing using statements AT NEW f and AT END OF f.
Originally this was defined for the obsolete technique of extracts and that is where the documentation can be found.
[<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm">Control Level Processing</a>]
The documentation for extract datasets applies exactly to internal tables:
The table mus be sorted to get control levels defined. A control break occurs when the value of the field f or a superior field in the current record has a different value from the previous record (AT NEW) or the subsequent record (AT END). Field f must be part of the header field group.
If the internal table is not sorted, the AT - ENDAT block is never executed.
Please have a look at the graphical demonstration of Control level processing in this document: <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm">Processing Table Entries in Loops</a>
Regards,
Clemens
BTW: Too bad we have anonymous MOD -
Using once created prepared statement with different connections in Oracle
Can I use same statement cash using different connections in Oracle
For example I have a prepared statement p1. After its using i close connection (return it to the pool)
Next time I want use p1 statement using another connection.
Question : When I creat p1 in second time ,is it returned from cash or created as a new statement. And what I should do to use once prepared statement using differend connections.
Thaks.As far as I know a PreparedStatement lives and dies with the Connection that created it. So, you cannot use a PreparedStatement with other Connection instances than the one that created it.
You will have to recreate the PreparedStatement for each time you open a connection, or use the same PreparedStatement and NOT close the Connection in between. The last suggestion can be risky though, if you never close the connection...
Jakob Jenkov
www.jenkov.com -
Comment regarding new statement of direction
Hi all,
I've just read the new statement of direction regarding Oracle Workflow (http://www.oracle.com/technology/products/ias/workflow/workflow_sod.html). Especially regarding the standalone version it is a great pitty that Oracle will kick such a good and stable product into the garbage can.
I'm not convinced that BPEL can replace Oracle Workflow. Also I'm missing a real migration path. It's not only Workflow that needs to be re-implemented. For example our custom application would have be to re-implemented as well because Workflow is one of the central components.
So if I read "In addition, Oracle are now recommending that customers who have Oracle Workflow workflows in development or production that they plan to continue to enhance in the future should begin re-implementing those in BPEL." or "While there will be some development costs associated with the migration of existing processes from Oracle Workflow to Oracle BPEL Process Manager..." this brings me to some critical thaughts about the future of our custom application.
What are your thaughts and comments?
Best regards
MatthiasThey also removed the entry about charting (Charting - Provide for chart rendering without using Flash (to enable display on mobile devices).)... Guess this will be in the next release (4.2) or next MAJOR release (5.0??)..
Thank you,
Tony Miller
Webster, TX
On the road of life...There are 'windshields', and there are 'bugs'
(splat!)
"Squeegees Wanted"
If this question is answered, please mark the thread as closed and assign points where earned.. -
Error at new statement on extended program check need help
Hi all ,
This is the code :
LOOP AT i_stocks INTO wa_stocks WHERE NOT pulkt IS INITIAL AND
NOT bstkt IS INITIAL AND
NOT fprctr IS INITIAL AND
( write_off_fix <> 0 OR
write_off_pup <> 0 ).
AT NEW fprctr.
CLEAR: l_prctrsum_fix, l_prctrsum_pup.
ENDAT.
IF wa_stocks-bukrs <> lastbukrs.
lastbukrs = wa_stocks-bukrs.
PERFORM document_header USING xreversal.
i_counter = 1.
CLEAR lastkostl.
ENDIF.
ADD wa_stocks-write_off_pup TO l_prctrsum_pup.
ENDLOOP
On Extended program check its says :
The LOOP statement processing will be limited
(FROM, TO and WHERE additions in LOOP)
Interaction with group change processing (AT NEW, ...) is undefined
(The message can be hidden with "#EC *)
It means at statement AT NEW fprctr .
Need help , How can i resolve this error ?
Regards .
Edited by: ujjwal dharmak on Feb 19, 2010 9:55 AM
Moderator message - Moved to the correct forum
Edited by: Rob Burbank on Feb 19, 2010 9:04 AMSince you are using where condition in loop statement and also using the control break statement thats why it is showing the error for you.
So if you want you can do like this
loop at itab into wa.
if not wa-f1 is initial ....<and other conditions>.
continue.
endif.
at new f1.
endat.
endloop.
It will resolve your problem but I am having the doubt how the at new will work properly...
Regards
Shiba Prasad Dutta -
Issue with : Stateful BSP Applications: New State Management Option
Reference:weblog by Thomas Jung - /people/thomas.jung3/blog/2004/11/09/updated-stateful-bsp-applications-new-state-management-option
I see a comment by one user to send the complete code... I am not sure what else can be sent - try it out rather than getting spoon-fed. - getting offline - sorry...
I had two issues with this ITSM way of session handling.
First - if you are using an SP42 environment, check CL_BSP_RUNTIME=>ON_SESSION_CMD() to see if CANCEL is defined as an option. If not make sure that you use &sap-sessioncmd=CLOSE" instead of the &sap-sessioncmd=CANCEL" . If CANCEL is not defined , it will give you shortdumps...
Second - when I closed the window, the session was not terminated. I used onbeforeUnLoad="exitBSPApplication(); instead of onUnLoad="exitBSPApplication(); and it worked fine. Not sure if it has any other issues.
But now I am facing a new issue... all but one application is not ending... I have no clue on why this is happening.. I am still checking..
Thanks Thomas, you are the best, as always...Thanks for checking the code in your system.
After some investigation, I found the behavior as explained below.
If the actual url has any fields passed as parameters, e.g.. /default.htm?var1=a&var2=2 ...
- if I use CANCEL as the option, a shortdump is created and the session is not closed. if I use CLOSE, Session is terminated and no shortdump happens.
If the actual url does not have any parameters, e.g.. /default.htm ...
- CANCEL does the work, but CLOSE does not exit the session.
In my applications I used request->get_form_fields to see if there are any parameters, and if there are, then I use CLOSE as the option and else, I use CANCEL. So now, the session
management works beautifully...
There is a good chance that I am doing something wrong here too. -
What is use of AT NEW and AT CHANGE
what is use of AT NEW and AT CHANGE
Using AT NEW
Use at new to detect a change in a column from one loop pass to the next. This statements enable you to execute code at the beginning of a group of records.
Syntax for the at new Statement
sort by c.
loop at it.
at new c.
endat.
endloop.
where:
it is an internal table.
c is a component of it.
The following points apply:
This statements can only be used within loop at; it cannot be used within select.
at new does not have to come before at end of. It can appear in any order.
This statement can appear multiple times within the same loop. For example, you could have two at new and three at end of statements within one loop and they can appear in any order.
These statements should not be nested inside of one another (that is, at end of should not be placed inside of at new / endat).
There are no additions to these statements.
Each time the value of c changes, the lines of code between at new and endat are executed. This block is also executed during the first loop pass or if any fields to the left of c change. Between at and endat, the numeric fields to the right of c are set to zero. The non-numeric fields are filled with asterisks (*). If there are multiple occurrences of at new, they are all executed. at end of behaves in a similar fashion.
A control level is the component named on a control break statement; it regulates the control break. For example, in the following code snippet, f2 is a control level because it appears on the at new statement.
loop at it.
at new f2.
"(some code here)
endat.
endloop.
It is said that a control break is triggered if the control level changes. This means that when the contents of the control level change, the code between the at and endat is executed.
A control break is also triggered if any of the fields prior to the control level in the structure change. Therefore, you should define the internal table structure to begin with the fields that form your control levels. You must also sort by all fields prior to and including c.
Between at and endat, numeric fields to the right of the control level will be zero and non-numeric fields will be filled with asterisks.
Using ON CHANGE OF
Another statement you can use to perform control break processing is on change of. It behaves in a manner similar to at new.
Syntax for the on change of Statement
The following is the syntax for the on change of statement.
on change of v1 or v2 .
else.
endon.
where:
v1 and v2 are variable or field string names.
any number of or conditions might follow.
The following points apply:
If the value of any of the variables (v1, v2, and so on) changes from one test to the next, the statements following on change of are executed.
If no change is detected and else is specified, the statements following else are executed.
on change of differs from at new in the following respects:
It can be used in any loop construct, not just loop at. For example, it can be used within select and endselect, do and enddo, or while and endwhile, as well as inside get events.
A single on change of can be triggered by a change within one or more fields named after of and separated by or. These fields can be elementary fields or field strings. If you are within a loop, these fields do not have to belong to the loop.
When used within a loop, a change in a field to the left of the control level does not trigger a control break.
When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
You can use else between on change of and endon.
You can use it with loop at it where . . ..
You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
Any values changed within on change of remain changed after endon. The contents of the header line are not restored as they are for at and endat.
When a loop begins execution, the system creates a global auxiliary field for each field named in an on change of statement contained by the loop. On creation, these fields are given default initial values (blanks or zeros). They are freed when the loop ends.
Each time on change of is executed, the contents of its fields are compared with the contents of the global auxiliary fields. If they are different, the on change of is triggered and the auxiliary fields are updated with the new values. If they are the same, the code within on change of is not executed
Because global auxiliary fields do not exist outside a loop, you cannot use on change of outside of a loop.
I hope it helps.
Best Regards,
Vibha
Please mark all the helpful answers -
Adding new state, it is not blank. CS6
when i create a new state some images from the first state appear on the stage and are locked and unselectable. I do not have a page set as master and all layers are unlocked. how do i create a blank state?
To create a blank state, go to the States panel and either click on the New/Duplicate State icon at the bottom or choose Add States… from the fly-out menu.
http://help.adobe.com/en_US/fireworks/cs/using/WS4c25cfbb1410b0021e63e3d1152b00db4b-7f72.h tml#WS4c25cfbb1410b0021e63e3d1152b00d51f-7ff1
Maybe you are looking for
-
SetBackground() Is Not Working in Windows 7
It looks like inheritance is broken in the component hierarchy for JFrame in Windows 7 JDK 1.6.0_23-b05. Run this code to reproduce the issue. public class Main public static void main(String[] args) JFrame frame = new JFrame(); frame.setTitle("Test
-
Converting string to date in mm/dd/yyyy format
Hi, I used simpledateformat to convert date to "MM/dd/yyyy" format. Now when i want to insert into db, i want the value as date object instead of string [returned by format method of SimpleDateFormat] what should i do? Date dt = new Date(); SimpleDat
-
Error in crystal external component has thrown an exception
When the customer tries to print a report in crystal send this error external component has thrown an exception
-
Today at 5:38 time machine did a backup (that worked) and since then it stopped backing up. I have: restarted ran disk utility on the drive - no errors unplugged it deleted last partial backup Still 874.12 GB free on disc nothing works...here is the
-
Hi All, I am using OBIEE11g in Linuc box.I tried all the forumns.Each one says different solution. My requirment is When i open http://ip:9704/analytics it should be display my company logo for hole page,Not for the banner only.How will do and what a