Vous êtes sur la page 1sur 13

APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Technical Design

Project: Priority:
Common Medium
Team: WBS Ref.:
Fulfill Demand Reports
Designed by:* Status:*
Kristin E. Salm 01 Draft in Progress
Signed-Off By: Sign-Off Date:

Release: Electronic Signature*


Release 1

Title:
Short Orders Within Tolerance

Functional Description:
This report will list open sales order lines meeting the
selection criteria for which goods have been issued, and the
total issued quantity is less than but within specified
tolerance of the ordered quantity. (See batch specification
for same gap.)

This report may be run stand alone. It will also be run as part
of the batch job, Close Completed Sales Order Lines.

Estimated Hours:
27

Actual Hours:
To be confirmed

Comments
None

Assigned To: Name of the Programmer

Other Affected Applications:


N/A

Z16830 1 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Technical Flow Diagram:

Report
ZFRD**** is
executed

Select-Options
and Parameters

Select data from


SAP tables

Determine which orders have been Exceeds Short Tolerance


delivered within the short tolerance
entered on the selection screen

Yes Within Short Tolerance

Print order

to screen

Z16830 2 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Audit/Checks:
N/A

Selection Criteria:
Sales Organization: From XXXX to XXXX
Sales Orders number: From 9999999999 to 9999999999
Close Short Order Tolerance: 99%

Report Layout(s):

The type of this report is ALV, to be generated via function module ‘REUSE ALV GRID
DISPLAY’.

Header:
Title: Report Sales Orders short Order tolerance
System Date (SY-DATUM)
Execution User (SY-USER)

Items Mapping:

Field Name Field Description Field Field Comments


Type Length
VBAK-KUNNR Sold-To customer C 10
VBAK-BSTNK Customer purchase C 20
order number
VBAK-VBELN Sales Document # C 10
VBAP-POSNR Item number C 6
VBAP-MATNR Material number C 18
VBAP-KDMAT Customer's Material # C 22
VBAP-KWMENG Ordered Qty quan 15
Variable to calculate the Cumulative Issued Qty quan 15
issued quantity

Items (Example)

Sold-to-Party Purchase Order Sales Line Material Customer Ordered Cumulative


Number Document Material Qty Issued Qty
45499 A903N4672HL0001 0000000152 000010 3000002 123456 1000 995
000020 3000003 123457 100 80
000030 3000004 123458 10 5
45500 A903N4672HL0002 0000000153 000010 4000002 223456 300 10
000020 4000003 223457 90 4

Z16830 3 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Sorted by fields:

Document Category, Sales Order Number and Sales Order Line Item.

Interactive Capabilities:
N/A
User-Exits:
N/A

SAP Transaction(s):
VA03 (Sales Orders), VL03 (Deliveries)

Operating Specifications

Frequency:
Daily

Dependencies:
Should be produced before MRP is run.

Restart/Recover Instructions:
N/A

Expected Duration:
3 Minutes

Responsible Contact:
Salvatore A. Schirripa

Assembly Testing Criteria

Test Conditions:
N/A

Follow-up

Issues:

Z16830 4 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Design

Program Description/Pseudocode:

Use judgement when extracting records from the database tables.

Know when to use SELECT... INTO CORRESPONDING FIELDS OF TABLE, SELECT SINGLE,
SELECT... FOR ALL ENTRIES IN TABLE itab, UP to 1 ROWS, etc.

When using SELECT... FOR ALL ENTRIES IN TABLE itab, ensure that itab is
not empty.

Declare internal tables to hold the values from each of your SELECT statements. Be sure
that each of these internal tables has at least one field the same as another of your
internal tables so as to be sure that there is some link between all your internal table
data.

Declare any necessary variables for your program.

Check return codes as necessary.

Make sure to clear and free internal tables when necessary.

Create subroutines encompassing major sections of your code (for example, you could
put all your initial table selections into a subroutine called GET_DATA) in order to
modularize program. Ideally, the main body of your program will be seen on one printed
page.

If you are calculating totals in your output loop and executing the output loop
write statements inside an ON CHANGE OF ... ENDON, make sure not to write
the first record to the screen (as the first record will always trigger the ON
CHANGE OF since the variable is going from no value to a value), use holding
variables for subtotals as well as any other output fields in order to write the
correct data to the screen.

Z16830 5 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

- SELECTION SCREEN –

SELECT OPTIONS: (For ranges)

Sales Organization S_VKORG for VBAK-VKORG, range, mandatory

Sales Document S_VBEL for VBAK-VBELN, range, optional

PARAMETERS (For single values)

Close Short Tolerance P_SHTTOL type n length 2 mandatory

- START OF SELECTION -

Obtain the data from the Sales Document: Header Data table (VBAK) for all
sales documents in Sales organization and Sales Document selected by the
user

Fields: VBAK-VBELN Sales document #


VBAK-VBTYP SD document category
VBAK-BSTNK Customer purchase order number
VBAK-KUNNR Sold-to party

Where: VKORG in S_VKORG and VBELN in S_VBELN

Place data into: corresponding fields of Sales Document: Header Data


internal table, I_VBAK

The following pseudo-code is how you would enter the syntax for the select described
above.

SELECT VBELN VBTYP BSTNK KUNNR

INTO TABLE I_VBAK

FROM VBAK

WHERE VKORG in S_VKORG

AND VBELN in S_VBELN

Z16830 6 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

IF SY-SUBRC <> 0

Message error ‘No data selected’

ENDIF

Sort I_VBAK by vbtyp vbeln.

Put together a list of all the documents selected above that have a
'Partially processed' (LFSTK='B') or 'Not Processed' (LFSTK= 'A') status by
doing a select on the Sales Document: Header Status table (VBUK) for all
entries in your Sales

Document: Header Data internal table

Before you go ahead and select your data using the FOR ALL ENTRIES command, you
must check if there are any entries in the internal table you are doing a FOR ALL ENTRIES
on (I_VBAK). This can be accomplished by checking the I_VBAK table with an IF
statement along with the initial command.

IF NOT I_VBAK IS INITIAL.

SELECT...
Fields: VBUK-VBELN Sales document #

VBUK-LFSTK Delivery Status

For all entries in I_VBAK where: VBELN = I_VBAK-VBELN


and the Delivery Status is classified as either 'partially
processed' or 'not processed'

Place data into: corresponding fields of Sales Document: Header Status


internal table (I_VBUK)

ENDIF.

Note: When using the FOR ALL ENTRIES command be sure to


apply this same IF logic around your select statements.

Since this report will only be dealing with sales documents that have not
been processed completely, we only need line item data from the Sales
Document: Item Data table (VBAP) for the sales documents just selected
from VBUK (accomplished by doing a select from VBAP for all entries in
I_VBUK)

Z16830 7 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Fields: VBAP-VBELN Sales document #


VBAP-POSNR Sales document item #
VBAP-MATNR Material #
VBAP-KWMENG Cumulative order quantity in sales units

For all entries in I_VBUK where: VBELN = I_VBUK-VBELN

Place data into: corresponding fields of Sales Document: Item Data


internal table, I_VBAP.

Remove from I_VBAP those items already delivered completely, since we


just want to report those items not yet delivered. To do so, access to
VBUP to check whether items from I_VBAP have been fully delivered and
remove those fully delivered (VBUP- LFSTK = ‘C’). Where ‘C’ equal to
COMPLETED DELIVERY.

To find the 'Issued Quantity' for each of these items, we need to find any
deliveries they may have been on. These delivery numbers can be found
via the Sales Document Flow table (VBFA) using a select from VBFA for all
entries in the SD: Item

Data internal table with the additional stipulation that the VBFA-VBTYP_N
field (Document category of subsequent document) is a delivery (VBFA-
VBTYP_N = 'I' or J').

Fields: VBFA-VBELV Sales document #

VBFA-POSNV Sales document item #

VBFA-VBELN Subsequent SD document # (Delivery Number)

VBFA-POSNN Subsequent SD document item # (Delivery Line

Item Number)

VBFA-RFMNG Referenced quantity in base units (equal to the


Issued Quantity in the case of a
delivery)

Note: The Delivery #(VBFA-VBELN) and The Delivery Line Item


#(VBFAPOSNN) are selected but are not used after the select. The
reason they are pulled from the database is because they make up
the unique key for the entries in the VBFA table. Take for instance
you have a sales order with one line item with a quantity of 1000

Z16830 8 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

lbs. From that sales order two deliveries were created: one
delivery with 500 lbs and another delivery for the remaining 500 lbs.
If you didn't select the subsequent SD document # and the
subsequent SD document item # the FOR ALL ENTRIES command
would only select one of the line items from vbfa. The delivery
number and line item number make the key unique. See your
reviewer for any questions or issues about this select.

For all entries in I_VBAP where:

VBELV = I_VBAP-VBELN
and POSNV = I_VBAP-
POSNR and VBTYP_N =
'I' or 'J'.

Place data into: corresponding fields of Sales Document: Item Data


internal table, I_VBFA

For each of the vbap records, loop at the Document flow internal table,
I_VBFA to get all the deliveries for this item. Each time through the loop,
add the quantity delivered (v_vbfa-rfmng) to v_cumqty.

LOOP AT I_VBFA INTO I_VBFA.

* When sales document number or line item change get item and
header data.

ON CHANGE OF...

Read I_VBAP and I_VBAK using your hold variable you store vbfa
info in at the bottum of the loop.

Divide v_cumqty by the ordered quantity v_vbap-kwmeng to get


the percentage delivered.

v_pctg = (v_cumqty/ v_vbap-kwmeng) * 100.

now subtract v_pctg from 1 to get the short percentage.

v_pctg = 100 - v_pctg.

Z16830 9 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

If this short percentage is less than or equal to the close short tolerance
parameter, place it in an output structure to be printed later. Otherwise,
clear the work areas and continue.

-Clear v_cumqty

ENDON.

* Move the contents of I_VBFA from the current loop pass, so you can use
it for the reads on I_VBAP and I_VBAK in your on change of logic.

* Calculate cumulative quantity delivered

v_cumqty = v_cumqty + v_vbfa-rfmng.

ENDLOOP.

Note: The ON CHANGE OF logic which is being used does nothing


to account for the last sales order in I_VBFA. Once you hit the last
record, there isn't any way for the program to process the logic that
is placed inside the ON CHANGE OF for the obvious reason. Make
sure you enter logic that will account for the last sales order or if
there is only one sales order in I_VBFA. See reviewer for any
questions or issues.

Z16830 10 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

- END OF SELECTION -

PRIMARY OPTION - Produce an ALV Report:

The following pseudo-code will generate the report ALV:

First of all, fill out the internal table I_FIELDCAT with the different ALV layout and
configuration parameters required by the function REUSE_ALV_GRID_DISPLAY

Fill out the internal table I_OUTPUT with the records selected from the data base (VBAK,
VBAP, VBFA, VBUK).

Call to the standard function REUSE_ALV_GRID_DISPLAY by exporting the internal tables


I_FIELDCAT and I_OUTPUT in order to trigger the ALV report in the screen, which is the
outcome of this program.

Z16830 11 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

Appendix: Report generation via obsolete ABAP technique ‘WRITE’

Just to mention about ‘WRITE’ reports. It was an old ABAP technique


used before ALV reports wherein the report and its lines were generated
by ‘WRITE’ sentence and by using a pseudo-code with this structure.

Nowadays, you will never need to create from scratch a ‘WRITE’ report,
since it is always used the ALV reports as this reports have more
functionality, are easier and faster to develop, and user friendly.

In any case, it is worth to know at least about its basic structure as you
might need to modify an already existing ‘WRITE’ report.

 Print the report by using this basic pseudo-code structure:

LOOP at output structure

AT NEW field.

NEW-PAGE

PERFORM WRITE_HEADER_INFO ‘Form that will write out header


information ENDON

* If no values for header data have changed, write next line item info

PERFORM WRITE_ITEM_INFO. ‘Form that will write out all detail information
without the headers

AT END OF field

PERFORM WRITE_SUBTOTALS

ENDAT

AT LAST

PERFORM WRITE_TOTALS.

WRITE ‘** end of list **’

Z16830 12 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***
APPLICATION DELIVERY FUNDAMENTALS: SAP ABAP CASE STUDY

END LAST

ENDLOOP.

Event TOP-OF-PAGE

PERFORM WRITE_NEW_PAGE_HEADER

Z16830 13 CASE Technical Design.doc


Copyright © 2011 Accenture. All Rights Reserved. ***Confidential – For Company Internal Use Only***

Vous aimerez peut-être aussi