Need a Logic for Rank
I have a Source Table
Column-1
Date
1111111111
03/01/2014
1111111111
03/8/2014
1111111111
03/15/2014
1111111111
03/22/2014
2222222222
03/01/2014
2222222222
03/8/2014
2222222222
03/15/2014
3333333333
03/01/2014
3333333333
03/8/2014
3333333333
03/15/2014
When the SSN change I want the rank to Change.
I want my target table as
Column-1
Date
Rank
1111111111
03/01/2014
1
1111111111
03/8/2014
2
1111111111
03/15/2014
3
1111111111
03/22/2014
4
2222222222
03/01/2014
1
2222222222
03/8/2014
2
2222222222
03/15/2014
3
3333333333
03/01/2014
1
3333333333
03/8/2014
2
3333333333
03/15/2014
3
Any Logic in BODS 4.1 to Achieve this ,Please let me know
Thanks
Madhu
Hello Madhu,
Refer this discussion, same sort of scenario has been discussed and solution suggested.
Similar Messages
-
Hi Experts,
I have a table
SSN data balance paid_amount rank
111111111 1st week date 1000 100 1
111111111 2nd week date 1000 100 2
111111111 3rd week date 1000 100 3
111111122 1st week date 1000 100 1
111111122 2nd week date 1000 100 2
111111122 3rd week date 1000 100 3
I want the output as
SSN data balance New_balance
111111111 1st week date 1000 1000
111111111 2nd week date 1000 900
111111111 3rd week date 900 800
111111122 1st week date 1000 1000
111111122 2nd week date 1000 900
111111122 3rd week date 900 800
For first New_balance values will be same as balance
for second week balance = new_balance and new_balance = balance-paid_amount
for third week balance = new_balance and new_balance = balance-paid_amount
I am using data service version 4.1
Need a Logic to perform above
Thanks
MadhuHi Mohd,
It worked Perfect for the new balance field, thank you so much, Also the balance field should change
In the above result set the 3rd Week balance should be same as 2nd week new balance
In other words, 2nd Week Balance should be same as first week new balance as shown below
Input
SSN
DATE
BALANCE
PAID_AMOUNT
111111111
1ST Week
1000
100
111111111
2nd Week
1000
100
111111111
3rd Week
1000
100
111111112
1ST Week
1000
100
111111112
2nd Week
1000
100
111111112
3rd Week
1000
100
111111112
4TH Week
1000
100
output
SSN
DATE
BALANCE
NEW_BALANCE
111111111
1ST Week
1000
1000
111111111
2nd Week
1000
900
111111111
3rd Week
1000
800
111111112
1ST Week
1000
1000
111111112
2nd Week
1000
900
111111112
3rd Week
1000
800
111111112
4TH Week
1000
700
Thanks for your Effort -
Need Mapping logic for the following scenario
Hi everyone,
I need a mapping logic for the following scenario.
For the same order no with same material no, the quantity should be summed and only one idoc should be created.
For the same order no with different material no, no need to sum the quantity and only one idoc should be created.
For example:
Source Structure:
Ord No Mat No QTY
12 1 2
13 1 3
13 2 1
12 2 4
15 1 5
14 3 7
12 1 6
Target Structure:
Ord No Mat No QTY
12 1 8
12 2 4
13 1 3
13 2 1
14 3 7
15 1 5
Thanks in AdvanceTry the graphical mapping as shown below using concat with a space as delimite and UDF to split the value again by space.
1. Idoc node
(RootContext)
OrdNo
|concat[ ] -> sort[asending] -> SplitByValue -> collapseContexts -> Idoc
MatNo case sensitive [ValueChange]
(RootContext)
2. OrdNo
OrdNo(RC)
|concat[ ] -> sort[asending] ->SplitByValue->collapseContexts->SplitByVale-> UDF to fetch ordno -> OrdNo
MatNo(RC) case sensitive [ValueChange] [eachValue] (return var1.split(" ")[0];)
3. MatNo
OrdNo(RC)
|concat[ ] -> sort[asending] -> SplitByValue ->collapseContexts->SplitByVale-> UDF to fetch ordno -> MatNo
MatNo(RC) case sensitive [ValueChange] [eachValue] (return var1.split(" ")[1];)
4. Qty
[asending,case sensitive]
-- sortByKey -----> formatByExample -> sum ->Qty
OrdNo(RC) | | ^
|concat[ ] -> | Qty(RC) |
MatNo(RC) | |
--sort[asending]-> SplitByValue
case sensitive [ValueChange]
Regards,
Sunil Chandra -
Need the Logic for this Prg issue Pls
Hi Friends,
i have an urgent requirement..
i am develop the report that is :
Based on Selction Critirea kunnr(knvv-kunnr)
i want Delete the
Internet mail (SMTP) address FROM ADR6-MTP_ADDR
AND Teletex number FROM ADR4-TTX_NUMBER..
USING TABLES ARE KNVV , ADR6 AND ADR4.
please how to Write the LOGIC For this Program .
help me.. it is an urgent.. anyone.
regards,Hi Alchermi,
thanks for your reply soon.
based on selction kunnr .. i want deete the ADR4-TTX_NUMBER..and ADR6-SMTP_ADDR From these 2 tables
for these 2 fields..
kunnr from knvv, selection field..
below fields want be DELETED..
ttx-number from adr4,
smtp_addr from adr6.
it is an urgent. help me .
regards, -
Need a logic for Internal table processing
Hi,
I have a requirement...an internal table contains three fields material no, bin no, and Quantity
Mat. No | Bin No | Quantity
a | x1 | 10
a | x1 | 10
a | x2 | 20
b | x3 | 10
c | x3 | 20
c | x4 | 30
c | x4 | 40
In this I need to append the records to new internal table say itab1 where multiple entries exist for some material no like mat no 'a' and 'c' and
if the material no. exist only once in the table, it has to be moved to another new internal table say itab2.
Pls suggest some logic that does not have performance issues.
Thanks in advance
SaravanaHi there,
a solution in brief...
data: wa_itab1_a like itab1,
wa_itab2_b like itab1,
lv_tabix type sytabix.
sort itab1 by matnr.
loop at itab1.
wa_itab1_a = itab1.
at new matnr.
lv_tabix = sy-tabix + 1.
clear wa_itab2_b.
READ TABLE itab1 into wa_itab2_b
INDEX lv_tabix.
if wa_itab2_b-matnr ne wa_itab1_a-matnr.
append wa_itab1_a to itab2.
delete itab1 where matnr = wa_itab1_a-matnr.
endif.
endat.
endloop.
Regards
George Zervas
Edited by: gzervas on Oct 20, 2010 12:08 PM -
Need reporting logic for Previous months sales compared to current month
Dear Folks,
I need to design a report that should give cumulative sales for the month compared with cumulative sales for the same date for previous months e.g. Sales upto 21st May should be compared with sales from 1st to 21st April, from 1st March to 21st March and so on.
Can anyone provide me a logic or CMOD code how to develop this report.
Will be great helpful.
Thanks in Advance.
RakeshHi Rakesh,
To accomplish the required output, you need to create variables that are input enabled and of processing type user eixt in the columns of your report in the query designer. I am assuming that, you would have atleast one variable which is input enabled and of processing type manual entry.
The user would input a date ( for example may 21) in this variable. You need to capture this value in the user eixt in I-STEP 2. From this value you need to calculate the previous month and pass it to the user exit variable. Below is a sample code,
----variable ZPREVDATE:pass the to value from variable ZCURRDAT -
DATA : LV_CALDAY TYPE SY-DATUM,
LS_T_VAR_RANGE TYPE i_t_var_range,
LV_YR(4), LV_MN(2), LV_DY(2).
WHEN 'ZPREVDATE'.
IF i_step = 2.
READ TABLE i_t_var_range INTO LS_T_VAR_RANGE
WITH KEY vnam = ZCURRDAT'.
LV_CALDAY = LS_T_VAR_RANGE-high.
LV_YR = LV_CALDAY+0(4).
LV_MN = LV_CALDAY+4(2).
LV_DY = LV_CALDAY+6(2).
LV_MN = LV_MN - 1.
CONCATENATE LV_YR LV_MN LV_DY INTO LV_CALDAY.
ls_range-low = LV_CALDAY.
ls_range-opt = 'EQ'.
ls_range-sign = 'I'.
APPEND ls_range TO e_t_range.
ENDIF.
The above code is a rough code that would help you to acheive your logic
Regards,
Prem -
I need a logic for the version management report
HI
Here with sending my req. Please give me the posible solution,its urgent,
1. Get all the objects included in a transport request by using function module
/DGN/ITC_TRANSPORT_TO_OBJECT.
2. Find the Objects which have the versions maintained in SAP.
3. Find the date on which the Transport request was released.
4. Find the date on which the object was changed.
5. Compare the date the TP was released and the date on which the object was changed, to find out the version of the object on the date when the Transport was released.
Output: Transport Request Number, Object Name, Object Type and Version
Thank you
sriniI can explain you the full logic of this FM but before that i would like to know if you are working for Data Domain?
Thanks
Yogesh Gupta -
Hi Experts ,
we have one requirement where in the legacy system ( Sender system) is sending .xml file and PI needs to pick the file and send it to ECC Via IDOC AAE Receiver Adapter to R/3 (SAP ECC) System .
The problem is the .xml file which PI receives is in a different format which is shown below
</tns:Header>
<tns:Body>
<esa:Payload>
<esa:Header>
<PayloadName></PayloadName>
<PayloadVersion>1.0</PayloadVersion>
<PayloadCreated>2014-01-07T02:39:55.793Z</PayloadCreated>
<PayloadSize units="Bytes">432</PayloadSize>
</esa:Header>
<esa:Data>
<zcs:HUM xmlns:zcs="com.">
<Hum_Number>00393155965135748871</Hum_Number>
<Source_Storage_Location>9000</Source_Storage_Location>
<Destination_Storage_Location>0100</Destination_Storage_Location>
<Material_Number>000000000000004123</Material_Number>
<Batch_Number>321940071 </Batch_Number>
<Quantity>0000000096000</Quantity>
<Production_Version>A100</Production_Version>
<Hostname>POSPI000003</Hostname>
</zcs:HUM>
</esa:Data>
</esa:Payload>
</tns:Body>
</tns:Envelope>|]
need help to convert this .xml into PI Standard xml format ( i mean without esa,zcs, ..So that at PI the message gets passed successfully without throwing xml parser issue or xml well not formed error .) .
do i need to write any java code for this ?
Please experts needs your suggestions here .
regards,
khan ,Hi Aziz,
please make sure your pasted xml has start and end tags
<tns:Body> </tns:Body>.
i don't think you need to change the external definition. make sure that you use xslt mapping first then message mapping.
Regards,
Muni. -
Need some logic for knowing closest Iternary Number for a Delivery
Hi Guys,
I have some requirement like below.
Let say for example I have a Delivery with No 8000001 with Iternary(Order) as 5 in workarea.
Let say I have one Internal Table with deliveries and Iternary no as below.
VBELN ITERN
8000002 2
8000003 4
8000004 3
8000005 1
8000006 6
How to get the value into another ITAB1 for 8000001 with Iternary 5 from the above mentioned workarea has the nearest Iternary value is
8000006 6
OR
8000003 4
from the above ITAB.
Thanks in Advance.
Prasad.
Edited by: Dheeru Prasad on Nov 30, 2009 10:04 PMmodify the code as per your need .
types : begin of ty_order,
vbeln type vbeln,
itern type i,
end of ty_order.
data : i_order type standard TABLE OF ty_order,
wa_order type ty_order,
wa_order_result type ty_order,
value type i,
l_value type i,
l_vbeln type vbeln,
l_itern type i,
l_tabix type sy-tabix.
wa_order-vbeln = '8000002'.
wa_order-itern = 2.
append wa_order to i_order.
wa_order-vbeln = '8000003'.
wa_order-itern = 4.
append wa_order to i_order.
wa_order-vbeln = '8000004'.
wa_order-itern = 3.
append wa_order to i_order.
wa_order-vbeln = '8000005'.
wa_order-itern = 1.
append wa_order to i_order.
wa_order-vbeln = '8000006'.
wa_order-itern = 6.
append wa_order to i_order.
l_vbeln = 8000001.
l_itern = 5.
loop at i_order into wa_order.
l_tabix = sy-tabix.
value = wa_order-itern - l_itern.
if value < 0.
value = value * ( - 1 ).
endif.
if l_tabix NE 1.
if value lt l_value.
l_value = value.
wa_order_result = wa_order.
endif.
else.
l_value = value.
wa_order_result = wa_order.
endif.
endloop.
write / : wa_order_result-vbeln , wa_order_result-itern . -
Need some logic for displaying data from Internal Table
Hi Guys,
I have a Internal Table with multiple entries.
My ITAB looks like below.
PN VBELN MATNR MATKX
1 111 P-101 XXX
2 121 P-102 XYZ
2 112 P-103 ABC
3 134 P-104 DEF
3 124 P-105 EFG
Now my requirement is I need to display the out put as follows through ALV or normal display.
<Header> <Date>
<Time>
PN = 1
VBELN MATNR MATKX
111 P-101 XXX
<Footer>
Some gap (May be a line to differentiate)
<Header > <Date>
<Time>
PN = 2
VBELN MATNR MATKX
121 P-102 XYZ
112 P-102 ABC
<Footer>
Some gap (May be a line to differentiate)
<Header > <Date>
<Time>
PN = 3
VBELN MATNR MATKX
134 P-104 DEF
124 P-105 EFG
<Footer>
Thanks in Advance.
Prasad.HI,
Use:
Data: W_PNlike PN.
LOOP AT ITAB.
If Itab-PN ne W_PN.
<Header> <Date>
<Time>
PN = 1.
VBELN MATNR MATKX >>>>>>>>>>>>>>>First Line enter
ELSE.
VBELN MATNR MATKX > line Next entry
ENDIF.
W_PN = ITAB-PN.
AT-END PN.
<Footer>
ENDAT.
ENDLOOP.
Hope this resolve your issue.
Regards,
Gurpreet -
Need a logic for creating SQL query
Hi Experts,
Could you please help me to get the follwing desired output . thanks
Actual Data:
ABC01-02
XYZ02-03
PQR78-79
LMN1-5
Expected/Desired Output:
ABC01
ABC02
XYZ02
XYZ03
PQR78
PQR79
LMN1
LMN5
Please let me know if you need any further information. Thanks in Advance.
Regards
RaghavHi!
In case you would like to get all entries:
WITH
mylist AS (SELECT 'ABC01-02' AS val FROM dual UNION ALL
SELECT 'XYZ02-03' AS val FROM dual UNION ALL
SELECT 'PQR78-79' AS val FROM dual UNION ALL
SELECT 'LMN1-5' AS val FROM dual
details AS (SELECT regexp_substr(val, '\D+') AS s,
to_number(regexp_substr(val, '\d+', 1, 1)) AS xfrom,
to_number(regexp_substr(val, '\d+', 1, 2)) AS xto,
lpad('0', length(regexp_substr(val, '\d+', 1, 2)), '0') as xpattern
FROM mylist
lines AS (SELECT ROWNUM AS yrow FROM dual CONNECT BY ROWNUM < 100
SELECT s || trim(to_char(yrow, xpattern)) AS xresult
FROM details JOIN lines ON (xfrom <= yrow AND xto >= yrow)
ORDER BY xresult;Result:
ABC01
ABC02
LMN1
LMN2
LMN3
LMN4
LMN5
PQR78
PQR79
XYZ02
XYZ03Best regards,
Matt
Edited by: Matt Schulz on 27.02.2013 14:41
Edited by: Matt Schulz on 27.02.2013 14:43 -
Need logic for invoice due date and discount due date uncear
Hi Experts.. am new to ABAP
i had an issue please need some logics for these..
Formatting of the Invoice due dates and Discount due date is unclear e.g 20101109,
Invoice due date and Discount due dates are in correct on 10 and 20 days reminders on missing credit notes for blocked invoices.
<removed by moderator>
Thanks & Regards
Edited by: Thomas Zloch on May 18, 2011 1:55 PMCan you provide more info?
are you talking about BSID open accounts?
if yes, use function module DETERMINE_DUE_DATE.
<removed by moderator>
Edited by: Thomas Zloch on May 18, 2011 2:10 PM - please do not ask for "award" -
Can Any one helpme with logic for fortnight
Hi All,
I need the logic for Fortnight of the year for drill in reports . Can any one help me regarding this.
Thanks in AdvanceHi,
I have built this logic to display the fortnights of current month plz modify this according to you requirmenet.
Here is the query....
SELECT case when getdate() between DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
and
dateadd(dd,14,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0) ) then 'Fnight-1' else 'Fnight-2' end
Cheers,
Ravichandra K -
In MVC, do i need a View or Page with flow logic for POPUP window
Hi All,
I have the below scenario using the MVC pattern.
I have a main view with 3 trays, each tray has two buttons, for example first tray has Create Order button. When I click on this button, I need a popup window to come with a tableview and a button(Create), where I select some rows and click on the button Create to create order.
But as per the MVC pattern I canu2019t call the view (popup) from another view(main view). So should I create a VIEW or PAGE WITH FLOW LOGIC for the popup? .
I need 6 popup to be called from the main view and once the function is done close the popup.
Please suggest me the flow for this scenario.
Cheers,
Srini.Srini,
1. You can call the view in pop-up because you will be calling the controller using open.window.
Here is the sample code:
method DO_REQUEST .
data:
li_vw type ref to if_bsp_page,
lv_form_field type string,
li_md type ref to zcl_model01.
dispatch_input( ).
li_md ?= get_model( 'm01' ).
lv_form_field = request->get_form_field( 'invoice_create' ).
if lv_form_field is initial.
*------ Request to display main page
li_vw = create_view( view_name = 'main.htm' ).
li_vw->set_attribute( name = 'model' value = li_md ).
call_view( li_vw ).
elseif lv_form_field eq 'true'.
*------ Request to display Invoice page in pop-up
li_vw = create_view( view_name = 'invoice.htm' ).
li_vw->set_attribute( name = 'model' value = li_md ).
call_view( li_vw ).
endif.
endmethod.
Layout:
function do_Invoice()
{ var s=0; r=1; w=300; h=300; x=screen.width/2;
x=x-w/2;
var y=screen.height/4;
y=y-h/2;
popUp=window.open('main.do?invoice_create=true','win','width='+ w
+',height='+ h +', left=' + x +',top='+ y +');
Option2:
Ofcourse you can't bind the model in page becos those are 2 different things. But all you need to do is access the model to get some value. To know how to access the model from Page w/flow logic look at [this link|Passing model reference to a page in a Popup].
Raja
Edited by: Raja Thangamani on Apr 14, 2009 11:22 AM -
Hi iam trying to get the po line item latest changedby name to display in my report
can you give me the logic to get the changed by name for theline item.
i have written the code but if i change the line item 20 then in the out put the changedby name is being displayed for line itema 10 ,20, 30 i e for all line items .but i want the changeby name to be displayed only for the particular line item which was changed.
*& Report ZMR_PO_AUDIT_RPT *
*& Purpose - Report on PO release details for auditing. *
Program ID : ZMR_PO_AUDIT_RPT *
Title : Purchase Release Audit Report *
Create Date : 19.03.2007 *
Author : Marina Gosman (JH IT services) *
Tech. Spec : *
Change Req #: *
Changed by | Description of change | Date *
MarinaG | Change the report Heading to Purchase | *
| Order Action Audit Report R3DK912376 |23.03.07 *
MarinaG | Fix a select bug. R3DK912384 |23.03.07 *
MarinaG | Change report heading by removing fields |27.03.07 *
| R3DK912404 | *
MarinaG | Add exception checkbox which will only |3.04.07 *
| show the same GR, Released and Created | *
| username R3DK912444. | *
MarinaG | Add GR Value and Vendor Name FP#1919 |28.08.07 *
| R3DK912809 | *
MarinaG | Add line item no., display line items for |11.10.07 *
| GR period and GR date FP#1919 R3DK912960 | *
REPORT ZSAMPLE3 NO STANDARD PAGE HEADING LINE-SIZE 200
MESSAGE-ID zv.
Database Tables
TABLES: ekko,t16fd,cdhdr,cdpos,t000,lfa1,t024,ekbe,mkpf.
TYPE-POOLS slis.
Type Declaration
*TYPE-POOLS: kkblo.
Structures
DATA:BEGIN OF st_output,
ebeln LIKE ekko-ebeln,
batxt LIKE t161t-batxt,
banfn LIKE eban-banfn,
bukrs LIKE ekko-bukrs,
frggr LIKE ekko-frggr,
frgsx LIKE ekko-frgsx,
frgct LIKE t16fd-frgct,
udate LIKE cdhdr-udate,
utime like cdhdr-utime,
username LIKE cdhdr-username,
lifnr LIKE ekko-lifnr, " vendor
name1 LIKE lfa1-name1, " vendor name
ebelp LIKE ekpo-ebelp, " line no.
afnam LIKE ekpo-afnam, " requisitioner
netwr LIKE ekpo-netwr,
ekgrp LIKE ekko-ekgrp,
eknam LIKE t024-eknam,
ernam LIKE ekko-ernam,
grnam LIKE ekbe-ernam,
bedat LIKE ekko-bedat,
budat LIKE ekbe-budat,
belnr LIKE ekbe-belnr, "R3DK912960
dmbtr LIKE ekbe-dmbtr, "R3DK912960
Indira
cdate LIKE cdhdr-username,
Indira
END OF st_output.
Indra
DATA: l_ponum LIKE ekko-ebeln,
l_poline LIKE ekpo-ebelp.
DATA: BEGIN OF t_EKbe OCCURS 0,
ebeln LIKE EKbe-ebeln,
belnr LIKE EKbe-Belnr,
budat LIKE EKbe-Budat,
cputm LIKE EKbe-cputm,
END OF T_EKbe.
DATA: BEGIN OF T_mkpf OCCURS 0,
mblnr LIKE mkpf-mblnr,
usnam LIKE mkpf-usnam,
END OF T_mkpf.
Internal Tables
DATA: t_cdhdr LIKE cdhdr OCCURS 0 WITH HEADER LINE,
t_cdhdr1 LIKE cdhdr OCCURS 0 WITH HEADER LINE,
po_ekko LIKE ekko OCCURS 0 WITH HEADER LINE.
Indra
DATA: t_cdpos LIKE cdpos OCCURS 0 WITH HEADER LINE.
indra
DATA: BEGIN OF tbl_output OCCURS 0.
INCLUDE STRUCTURE st_output.
DATA: END OF tbl_output.
DATA: BEGIN OF tbl_ekpo OCCURS 0.
INCLUDE STRUCTURE ekpo.
DATA: END OF tbl_ekpo.
DATA: BEGIN OF tbl_ekbe OCCURS 0.
INCLUDE STRUCTURE ekbe.
DATA: END OF tbl_ekbe.
DATA: BEGIN OF t_ekko OCCURS 0,
ebeln TYPE ebeln,
ebelp TYPE ebelp, "R3DK912960
belnr TYPE MBLNR, "R3DK912960
bukrs TYPE bukrs,
bsart TYPE bsart,
bedat TYPE bedat,
budat TYPE budat,
ernam TYPE ernam,
grnam TYPE ernam,
dmbtr TYPE dmbtr, "R3DK912960
END OF t_ekko.
DATA: c_tcode(25) TYPE c.
DATA: st_fieldcat TYPE slis_fieldcat_alv.
DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv.
DATA: st_event TYPE slis_alv_event.
DATA: tbl_events TYPE slis_t_event.
DATA: fieldname(30) TYPE c.
DATA: st_layout TYPE slis_layout_alv.
DATA: g_status TYPE slis_formname VALUE 'STANDARD01'.
DATA: g_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
DATA: st_status TYPE slis_status.
DATA: tbl_status TYPE slis_status OCCURS 0 WITH HEADER LINE.
DATA: f_ebeln LIKE ekko-ebeln.
DATA: cursorfield LIKE ekko-ebeln.
DATA: ws_ebeln LIKE ekko-ebeln,
ws_netwr LIKE ekpo-netwr,
ws_ernam LIKE ekbe-ernam,
rs_selfield TYPE slis_selfield,
ws_dmbtr LIKE ekbe-dmbtr. "R3DK912809
RANGES: r_kunnr FOR vbak-kunnr OCCURS 0.
Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK title WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR ekko-bukrs OBLIGATORY,
s_ekorg FOR ekko-ekorg OBLIGATORY,
s_ebeln FOR ekko-ebeln,
s_groups FOR ekko-ekgrp,
s_lifnr FOR ekko-lifnr,
s_bedat FOR ekko-bedat,
s_budat FOR ekbe-budat,
s_bsart FOR ekko-bsart.
SELECTION-SCREEN END OF BLOCK title .
SELECTION-SCREEN BEGIN OF BLOCK title2 WITH FRAME TITLE text-001.
PARAMETERS: p_gr AS CHECKBOX DEFAULT 'X',
p_excep AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK title2 .
*& AT SELECTION SCREEN
AT SELECTION-SCREEN.
IF NOT p_gr IS INITIAL.
IF s_budat IS INITIAL.
MESSAGE s000 WITH 'Please enter Goods Receipt Date.'.
STOP.
ENDIF.
ELSE.
IF s_bedat IS INITIAL.
MESSAGE s000 WITH 'Please enter Purch Doc Date.'.
STOP.
ENDIF.
ENDIF.
START-OF-SELECTION.
START-OF-SELECTION.
PERFORM select_data. " Select data
PERFORM sort_table.
PERFORM get_events. " Include header in display
PERFORM get_eventstatus. " Set the GUI status
PERFORM get_layout. " Define ALV Layout
PERFORM get_fieldcat. " Fill report fields
PERFORM create_report. " Write ALV format
AT LINE-SELECTION.
PERFORM user_command USING sy-ucomm
rs_selfield.
FORM user_command *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: l_ta TYPE sy-tcode VALUE 'SLIS_DUMMY'.
CLEAR: f_ebeln.
CASE r_ucomm.
WHEN 'CF1'.
READ TABLE tbl_output INDEX rs_selfield-tabindex.
IF sy-subrc = 0.
f_ebeln = tbl_output-ebeln.
ENDIF.
SET PARAMETER ID 'BES' FIELD f_ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
Begin of R3DK912404
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
End of R3DK912404
WHEN 'OTHERS'.
ENDCASE.
ENDFORM. "user_command
FORM STANDARD_02 *
--> EXTAB *
FORM standard_01 USING extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD01' EXCLUDING extab .
ENDFORM. "standard_01
*& Form get_events
setup report headings
--> p1 text
<-- p2 text
FORM get_events.
CLEAR st_event.
st_event-name = 'TOP_OF_PAGE'.
st_event-form = 'PROCESS_TOP_OF_PAGE'.
APPEND st_event TO tbl_events.
ENDFORM. " get_events
FORM get_eventstatus *
FORM get_eventstatus.
CLEAR st_status.
st_status-callback_pf_status_set = 'STANDARD_01'.
APPEND st_status TO tbl_status.
ENDFORM. " get_eventstatus
*& Form get_layout
text
--> p1 text
<-- p2 text
FORM get_layout.
CLEAR st_layout.
st_layout-zebra = 'X'.
ENDFORM. " get_layout
*& Form get_fieldcat
text
--> p1 text
<-- p2 text
FORM get_fieldcat.
PERFORM write_fieldcat USING 'EBELN' 'TBL_OUTPUT' 'EKKO' 'X' 1 ' '.
PERFORM write_fieldcat USING 'BUKRS' 'TBL_OUTPUT' 'EKKO' 'X' 2 ' '.
Begin of R3DK912960
PERFORM write_fieldcat USING 'EBELP' 'TBL_OUTPUT' 'EKPO' 'X' 3 ' '.
End of R3DK912960
PERFORM write_fieldcat USING 'UDATE' 'TBL_OUTPUT' ' ' ' ' 4
'Doc. Date'.
PERFORM write_fieldcat USING 'UTIME' 'TBL_OUTPUT' ' ' ' ' 13
'Doc. Time'.
Begin of R3DK912960
PERFORM write_fieldcat USING 'BUDAT' 'TBL_OUTPUT' ' ' ' ' 5
'GR Date'.
End of R3DK912960
PERFORM write_fieldcat USING 'ERNAM' 'TBL_OUTPUT' ' ' ' ' 6
'Created By'.
PERFORM write_fieldcat USING 'USERNAME' 'TBL_OUTPUT' ' ' ' ' 7
'Released By'.
PERFORM write_fieldcat USING 'GRNAM' 'TBL_OUTPUT' ' ' ' ' 8
'Goods Receipted By'.
PERFORM write_fieldcat USING 'CDATE' 'TBL_OUTPUT' ' ' ' ' 9
'Changed By'.
PERFORM write_fieldcat USING 'NETWR' 'TBL_OUTPUT' ' ' ' ' 10
'Total Value'.
PERFORM write_fieldcat USING 'EKGRP' 'TBL_OUTPUT' 'EKKO' ' ' 11 ' '.
Begin of R3DK912809
PERFORM write_fieldcat USING 'DMBTR' 'TBL_OUTPUT' ' ' ' ' 12
'GR Value '.
PERFORM write_fieldcat USING 'NAME1' 'TBL_OUTPUT' ' ' ' ' 13
'Vendor Name'.
End of R3DK912809
ENDFORM. " get_fieldcat
FORM process_top_of_page *
FORM process_top_of_page.
SKIP.
ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED OFF .
Begin of R3DK912376
WRITE:/ 'Report Name : PO Release Audit Report',
WRITE:/ 'Report Name : Purchase Order Actions Report',
End of R3DK912376
/ 'Run Date : ', sy-datum,
/ 'Run Time : ', sy-uzeit,
Begin of R3DK912404
/ 'Document Type : ', c_tcode,
End of R3DK912404
/ 'Company code : ', s_bukrs-low.
IF NOT s_bukrs-high IS INITIAL.
WRITE: 'To', s_bukrs-high.
ENDIF.
WRITE:/ 'Purch Org : ', s_ekorg-low.
IF NOT s_ekorg-high IS INITIAL.
WRITE: 'To', s_ekorg-high.
ENDIF.
Begin of R3DK912404
WRITE:/ 'Purchase Order : ', s_ebeln-low.
IF NOT s_ebeln-high IS INITIAL.
WRITE: 'To', s_ebeln-high.
ENDIF.
WRITE:/ 'Purchasing Grp : ', s_groups-low.
IF NOT s_groups-high IS INITIAL.
WRITE: 'To', s_groups-high.
ENDIF.
WRITE:/ 'Vendor : ', s_lifnr-low.
IF NOT s_lifnr-high IS INITIAL.
WRITE: 'To', s_lifnr-high.
ENDIF.
WRITE:/ 'Goods Receipt Date:', s_budat-low.
IF NOT s_budat-high IS INITIAL.
WRITE: 'To', s_budat-high.
ENDIF.
End of R3DK912404
WRITE:/ 'Purch Doc Date : ', s_bedat-low.
IF NOT s_bedat-high IS INITIAL.
WRITE: 'To', s_bedat-high.
ENDIF.
Begin of R3DK912404
WRITE:/ 'Purch Doc Type : ', s_bsart-low.
IF NOT s_bsart-high IS INITIAL.
WRITE: 'To', s_bsart-high.
ENDIF.
End of R3DK912404
ULINE.
FORMAT COLOR COL_HEADING INTENSIFIED OFF.
ENDFORM. " process_top_of_page
*& Form create_report
text
--> p1 text
<-- p2 text
FORM create_report.
SORT tbl_output BY ebeln ebelp.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_events = tbl_events
i_interface_check = ' '
i_callback_program = 'ZSAMPLE3'
i_callback_pf_status_set = g_status
i_callback_user_command = g_user_command
is_layout = st_layout
it_fieldcat = tbl_fieldcat
i_default = 'X'
i_save = 'X'
TABLES
t_outtab = tbl_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " create_report
*& Form select_data
select records for specified selections
--> p1 text
<-- p2 text
FORM select_data.
CLEAR: c_tcode, t_cdhdr, t_ekko, tbl_output.
REFRESH: t_cdhdr, t_ekko, tbl_output, tbl_fieldcat.
IF NOT p_gr IS INITIAL.
SELECT DISTINCT a~ebeln "R3DK912960
SELECT a~ebeln "R3DK912960
b~ebelp "R3DK912960
b~belnr
a~bukrs
a~bsart
a~bedat
b~budat
a~ernam
b~ernam
INTO TABLE t_ekko
FROM ekko AS a
INNER JOIN ekbe AS b
ON aebeln = bebeln
Begin of R3DK912384
AND b~bewtp = 'E'
AND b~bwart = '101'
End of R3DK912384
WHERE a~bukrs IN s_bukrs AND
a~ebeln IN s_ebeln AND
a~ekgrp IN s_groups AND
a~lifnr IN s_lifnr AND
a~bsart IN s_bsart AND
a~ekorg IN s_ekorg and
a~bedat IN s_bedat AND
b~budat IN s_budat AND
a~frgke = 'R'
ORDER BY aebeln bbudat DESCENDING.
Begin of R3DK912809 R3DK912960
DELETE ADJACENT DUPLICATES FROM T_EKKO COMPARING EBELN.
End of R3DK912809 R3DK912960
ELSE.
SELECT DISTINCT a~ebeln "R3DK912960
SELECT a~ebeln "R3DK912960
b~ebelp "R3DK912960
b~belnr
a~bukrs
a~bsart
a~bedat
b~budat
a~ernam
b~ernam
INTO TABLE t_ekko
FROM ekko AS a
LEFT JOIN ekbe AS b
ON aebeln = bebeln
Begin of R3DK912384
AND b~bewtp = 'E'
AND b~bwart = '101'
End of R3DK912384
WHERE a~bukrs IN s_bukrs AND
a~ebeln IN s_ebeln AND
a~ekgrp IN s_groups AND
a~lifnr IN s_lifnr AND
a~bsart IN s_bsart AND
a~ekorg IN s_ekorg AND
a~bedat IN s_bedat AND
a~frgke = 'R'
ORDER BY aebeln bbudat DESCENDING.
Begin of R3DK912809 R3DK912960
DELETE ADJACENT DUPLICATES FROM T_EKKO COMPARING EBELN.
End of R3DK912809 R3DK912960
ENDIF.
sort t_ekko by ebeln ebelp budat descending.
sivanew
delete adjacent duplicates from t_ekko comparing ebeln ebelp .
sivanew
IF sy-subrc EQ 0. "R3DK912809
IF NOT t_ekko[] IS INITIAL. "R3DK912809
PERFORM process_data.
Begin of R3DK912444
IF NOT p_excep IS INITIAL.
PERFORM get_exceptions.
ENDIF.
End of R3DK912444
ENDIF.
ENDFORM. " select_data
*& Form write_fieldcat
text
-->P_0190 field name, if the SAP name used desc will be
automatically get from SAP table
-->P_0191 Internale structure or table name
-->P_0192 SAP table for field description
-->P_0193 format
-->P_1 Position
-->P_0195 Custom Description
FORM write_fieldcat USING name tab st key pos desc.
st_fieldcat-fieldname = name.
st_fieldcat-tabname = tab.
st_fieldcat-ref_tabname = st.
st_fieldcat-key = key.
st_fieldcat-col_pos = pos.
st_fieldcat-seltext_m = desc.
IF pos = 12.
st_fieldcat-outputlen = 40.
ENDIF.
APPEND st_fieldcat TO tbl_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " write_fieldcat
*& Form process_record
text
--> p1 text
<-- p2 text
FORM process_record.
DATA:l_ebeln LIKE ekko-ebeln.
LOOP AT t_cdhdr.
CLEAR: l_ebeln, ws_ebeln, ws_netwr, ws_ernam.
MOVE t_cdhdr-objectid TO l_ebeln.
CALL FUNCTION 'ME_EKKO_SINGLE_READ'
EXPORTING
pi_ebeln = l_ebeln
IMPORTING
po_ekko = po_ekko.
Begin of R3DK912809 R3DK912960
SELECT SUM( dmbtr ) INTO ws_dmbtr
FROM ekbe WHERE ebeln = l_ebeln
AND vgabe = '1'
AND bewtp = 'E'
GROUP BY ebeln.
ENDSELECT.
End of R3DK912809
SELECT SINGLE dmbtr INTO t_ekko-dmbtr
FROM ekbe WHERE ebeln = t_ekko-ebeln
AND ebelp = t_ekko-ebelp
AND belnr = t_ekko-belnr
AND vgabe = '1'
AND bewtp = 'E'.
MODIFY T_EKKO.
End of R3DK912960
SELECT SINGLE ernam INTO t_ekko-grnam
FROM ekbe WHERE ebeln = t_ekko-ebeln
AND ebelp = t_ekko-ebelp
AND ELIKZ = 'X'.
MODIFY T_EKKO.
SELECT ebeln SUM( netwr ) INTO (ws_ebeln, ws_netwr)
FROM ekpo WHERE ebeln = l_ebeln R3DK912960
FROM ekpo WHERE ebeln = t_ekko-ebeln "R3DK912960
GROUP by ebeln.
ENDSELECT.
IF sy-subrc EQ 0.
IF s_groups IS INITIAL.
PERFORM build_output.
ELSE.
IF po_ekko-ekgrp IN s_groups.
PERFORM build_output.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " process_record
*& Form get_customer
Get Customers if sales office specified
--> p1 text
<-- p2 text
*& Form build_output
text
--> p1 text
<-- p2 text
FORM build_output.
DATA: l_line LIKE ekpo-ebelp.
DATA: l_requisitioner LIKE ekpo-afnam.
IF po_ekko-frgke = 'R'.
CLEAR: tbl_output.
tbl_output-udate = t_cdhdr-udate.
tbl_output-utime = t_cdhdr-utime.
tbl_output-username = t_cdhdr-username.
tbl_output-ebeln = po_ekko-ebeln.
tbl_output-bukrs = po_ekko-bukrs.
tbl_output-lifnr = po_ekko-lifnr.
tbl_output-name1 = ' '.
tbl_output-lifnr = po_ekko-lifnr.
tbl_output-ekgrp = po_ekko-ekgrp.
tbl_output-ernam = po_ekko-ernam.
tbl_output-ernam = t_ekko-ernam.
tbl_output-budat = t_ekko-budat.
tbl_output-grnam = t_ekko-grnam.
tbl_output-bedat = t_ekko-bedat.
tbl_output-dmbtr = t_ekko-dmbtr. "R3DK912809
tbl_output-ebelp = t_ekko-ebelp.
SORT T_CDHDR1.
sivanew
read table t_cdhdr1 with key
objectid = t_cdhdr-objectid binary search.
if sy-subrc = 0.
tbl_output-cdate = t_cdhdr1-username.
endif.
read table t_cdhdr1 with key
tcode = 'ME22N' binary search.
if sy-subrc = 0.
SELECT * FROM cdpos INTO TABLE t_cdpos
WHERE objectid = t_cdhdr1-objectid AND
objectclas = 'EINKBELEG' AND
changenr = t_cdhdr1-changenr.
IF sy-subrc = 0.
l_ponum = t_cdpos-tabkey+3(10).
l_poline = t_cdpos-tabkey+13(6).
ENDIF.
ENDIF.
IF tbl_output-ebeln = l_ponum AND tbl_output-ebelp = l_poline.
READ TABLE t_cdhdr1 WITH KEY changenr = t_cdpos-changenr
tcode = 'ME22N' BINARY SEARCH.
IF sy-subrc = 0.
tbl_output-cdate = t_cdhdr1-username.
ENDIF.
ENDIF.
ENDIF.
select ebeln belnr budat cputm from ekbe into table t_ekbe
where vgabe = '1' and
ebeln = t_cdhdr-objectid.
sort t_ekbe by budat descending cputm descending.
delete adjacent duplicates from t_ekbe comparing ebeln.
loop at t_ekbe.
select mblnr usnam from mkpf into table t_mkpf
where mblnr = t_ekbe-belnr.
if sy-subrc = 0.
read table t_mkpf with key
mblnr = t_ekbe-belnr binary search.
move t_mkpf-usnam to tbl_output-grnam.
endif.
endloop.
Indra
Get the user changed the record
IF t_cdhdr-tcode = 'ME22N'.
SELECT * FROM cdpos INTO TABLE t_cdpos
WHERE objectid = t_cdhdr-objectid AND
objectclas = 'EINKBELEG' AND
changenr = t_cdhdr-changenr.
IF sy-subrc = 0.
l_ponum = t_cdpos-tabkey+3(10).
l_poline = t_cdpos-tabkey+13(6).
ENDIF.
ENDIF.
indra
Display creator or changer
IF tbl_output-ebeln = l_ponum AND tbl_output-ebelp = l_poline.
READ TABLE t_cdhdr WITH KEY changenr = t_cdpos-changenr
tcode = 'ME22N' BINARY SEARCH.
IF sy-subrc = 0.
tbl_output-cdate = t_cdhdr-username.
ENDIF.
ENDIF.
Indra
SELECT SINGLE * FROM t024
WHERE ekgrp = po_ekko-ekgrp.
IF sy-subrc EQ 0.
tbl_output-eknam = t024-eknam.
ENDIF.
tbl_output-netwr = ws_netwr.
SELECT SINGLE name1 FROM lfa1
INTO tbl_output-name1
WHERE lifnr = po_ekko-lifnr.
Get Document descriptions
SELECT SINGLE batxt FROM t161t
INTO tbl_output-batxt
WHERE spras = 'E' AND
bsart = po_ekko-bsart AND
bstyp = po_ekko-bstyp.
Get Release code descriptions
SELECT SINGLE frgct FROM t16fd
INTO tbl_output-frgct
WHERE spras = 'E' AND
frggr = po_ekko-frggr AND
frgco = po_ekko-frgsx.
APPEND tbl_output.
ENDIF.
ENDFORM. " build_output
*& Form SORT_TABLE
text
--> p1 text
<-- p2 text
FORM sort_table.
SORT tbl_output BY ebeln ebelp ascending udate utime DESCENDING.
SORT tbl_output BY ebeln ascending udate utime DESCENDING.
delete adjacent duplicates from tbl_output comparing ebeln ebelp .
ENDFORM. " SORT_TABLE
*& Form PROCESS_DATA
text
--> p1 text
<-- p2 text
FORM process_data.
LOOP AT t_ekko.
c_tcode = 'Purchase Orders'.
SELECT * FROM cdhdr UP TO 1 ROWS INTO TABLE t_cdhdr "R3DK912960
SELECT * FROM cdhdr into table t_cdhdr
WHERE objectclas = 'EINKBELEG' AND
objectid = t_ekko-ebeln AND
tcode = 'ME28'.
SORT T_CDHDR BY UDATE DESCENDING UTIME DESCENDING.
delete adjacent duplicates from t_cdhdr comparing objectid.
siva
SELECT * FROM cdhdr UP TO 1 ROWS INTO TABLE t_cdhdr1
*"R3DK912960
SELECT * FROM cdhdr INTO TABLE t_cdhdr1
WHERE objectclas = 'EINKBELEG' AND
objectid = t_ekko-ebeln AND
tcode = 'ME22N'.
SORT T_CDHDR1 BY UDATE descending UTIME DESCENDING.
delete adjacent duplicates from t_cdhdr1 comparing objectid.
sivanew
if c_tcode = 'ME22N'.
SELECT * FROM cdpos INTO TABLE t_cdpos
WHERE objectid = t_cdhdr1-objectid AND
objectclas = 'EINKBELEG' AND
changenr = t_cdhdr1-changenr.
IF sy-subrc = 0.
l_ponum = t_cdpos-tabkey+3(10).
l_poline = t_cdpos-tabkey+13(6).
ENDIF.
ENDIF.
*sivanew
IF sy-subrc = 0.
delete adjacent duplicates from t_cdhdr comparing objectid.
PERFORM process_record. " process each document
ENDIF.
ENDLOOP.
ENDFORM. " PROCESS_DATA
*& Form get_exceptions
text
--> p1 text
<-- p2 text
form get_exceptions.
Display a report which shows the same released, goods receipted and
created by user
LOOP AT tbl_output.
IF tbl_output-username <> tbl_output-ernam OR
tbl_output-ernam <> tbl_output-grnam.
DELETE tbl_output.
ENDIF.
ENDLOOP.
endform. " get_exceptionsHi,
first of all you should read the following thread ABAP Development It is really hard to read code without proper formatting.
It looks like you use change documents to get user name for last change. For each document you use last change document and hence you have same name for every item. I am not sure if it is possible (it should be) but for each item you need to look for last change document corresponding to this item.
Cheers
Maybe you are looking for
-
SY - System fields and return codes in ABAP
Hi I'm new to ABAP, where do I find what the meaning of the system field return codes are ? example SY-SUBRC returns a number of codes 0, 2, 4, 8 etc what do they mean. Is there a resource somewhere that provides this information for all the system f
-
Difficulty detecting SATA disk, adding a second SATA disk, memory conflict, etc
I resolved the SATA problem in the middle of writing this post, but for others’ benefit in the future, I am still describing it here. But there are still some unresolved problems. ======================================================== I have an In
-
Outlook Calendar & problem with Invitations
Exchange calendar sync fine, but there's an interaction question or problem. SCENARIO: --Calendar entry is in Outlook, as "accepted", with this acceptance coming from me on Windows desktop. --Receive a Duplicate "invitation" on the iPhone. --On the i
-
First off let me say I love the idea of syncing wirelessly. That being said I reall wish apple would get it figured out. Ever since they updated to itunes 10.5 and iOS 5 with "wireless" syncing I have had problems with all of my devices syncing. In p
-
External Reference number not copied in Service Confirmation
Hi, We are on CRM 5.0 SP11. We have Mobile Service 5.0 SP11. In Mobile Service in the Service Order creation screen we have a window to input External reference number. When we create a Service Confirmation as a followup document of Service Order, SA