Project 7 Internal Tables II

Total Page:16

File Type:pdf, Size:1020Kb

Project 7 Internal Tables II

Project 7 Internal Tables II

Project Overview

Create an ABAP Program that will produce a summary report of dollars spent on Purchase Orders for a given date range. Display the sum by purchase organization and then purchasing group.

The key to this program is loading everything into an internal table first. This makes the select very fast then manipulating the data using the 'at new' and 'at end of' statements in the internal table

Project Specifics/Requirements

For the report statement, add the following attribute:

no standard page heading line-size 132

The Tables for this program are:

Ekko PO table Ekpo PO line item table

Creat an internal table that contains the structure of the following fields:

ekko-ekorg ekko-ekgrp ekko-ebeln ekpo-brtwr

Use the following code for using Parameters: selection-screen begin of block thread. selection-screen comment /1(83) text-003.

Parameters: r1 radiobutton group decd default 'X', r2 radiobutton group decd.

selection-screen uline. selection-screen end of block thread. Use Select-Options as displayed below: select-options: s_ekorg for ekko-ekorg, s_ekgrp for ekko-ekgrp, s_bukrs for ekko-bukrs, s_bsart for ekko-bsart default 'PO', s_bedat for ekko-bedat.

Create a conditional statement that checks the value of the radio button and calls the appropriate subroutine. if r1 eq 'X'. perform summary. else. perform detail. endif.

For the Summary Subroutine, create variables that will store the group and organization summary amounts.

Note: that the internal table must be organized in the order in which you want to break on the data. In addition you need to sort the table in the sort order as well before you start to process it. This is key if you don't you will miss data

sort itab by ekorg ekgrp.

loop at itab.

at new ekorg. write: /2 itab-ekorg. endat.

at new ekgrp. write: /5 itab-ekgrp. endat.

Var1 = Var1 + itab-brtwr.

at end of ekgrp. write: at 15 Var1.

Var2 = Var2 + Var1.

clear Var1.

endat.

at end of ekorg.

write: /2(40) sy-uline. write: /2 'Purchasing Org Total: ', Var2.

clear Var2. endat.

endloop.

ENDFORM

Create a Subroutine for the details. Declare 3 variables to store the values

Note: that the internal table must be organized in the order in which you want to break on the data. In addition you need to sort the table in the sort order as well before you start to process it. This is key if you don't you will miss data

sort itab by ekorg ekgrp ebeln.

loop at itab.

at new ekorg. write: /2 itab-ekorg. endat.

at new ekgrp. write: /5 itab-ekgrp. endat.

at new ebeln. write: /8 itab-ebeln. endat.

Var3 = Var3 + itab-brtwr.

at end of ebeln.

write: at 25 Var3.

Var1 = Var1 + Var3.

clear Var3.

endat.

at end of ekgrp.

write: /2(50) sy-uline.

write: /2 'Purchasing Grp Total: ', Var1.

skip.

Var2 = Var2 + Var1.

clear Var1.

endat. at end of ekorg.

skip.

write: /2(50) sy-uline. write: /8 'Purchasing Org Total: ', Var2.

clear Var2.

endat.

endloop.

ENDFORM.

Create a Sub Routine that gets the data. Use the example below.

select ekorg ekgrp ebeln into (ekko-ekorg, ekko-ekgrp, ekko-ebeln) from ekko where ekorg in s_ekorg and ekgrp in s_ekgrp and bukrs in s_bukrs and bsart in s_bsart and bedat in s_bedat.

select brtwr into ekpo-brtwr from ekpo where ebeln = ekko-ebeln.

itab-ekorg = ekko-ekorg. itab-ekgrp = ekko-ekgrp. itab-ebeln = ekko-ebeln. itab-brtwr = ekpo-brtwr.

append itab.

endselect.

endselect.

ENDFORM.

Recommended publications