You are on page 1of 6

*&---------------------------------------------------------------------*

*& Report ZDEMO8


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDEMO8 NO STANDARD PAGE HEADING LINE-COUNT 20 LINE-SIZE 150 MESSAGE
-ID zmsg.

TYPES : BEGIN OF ty_lfa1,


lifnr TYPE lifnr ,
name1 TYPE name1,
land1 TYPE land1 ,
ort01 TYPE ort01,
anred TYPE anred,
END OF ty_lfa1.

" table structure for the basic list


" vendor number
" name
" country
" city
" title

data : wa_lfa1 TYPE ty_lfa1 , " work area for the basic structure
it_lfa1 TYPE TABLE OF ty_lfa1. " interanl table for basic structu
re
"--------------------- LFA1
TYPES : BEGIN OF ty_ekko,
lifnr TYPE lifnr,
ebeln TYPE ebeln,
bstyp TYPE bstyp,
ekorg TYPE ekorg,
END OF ty_ekko.

" table structure for secondary list


" vendor number
" purchase document number
" purchase document category
" purchasing organisation

DATA : wa_ekko TYPE ty_ekko , " work area for the secondary list
it_ekko TYPE TABLE OF ty_ekko . " interanal table for seconda
ry list
"---------------------EKKO
TYPES

: BEGIN OF ty_ekpo,
ebeln TYPE ebeln, " purchase document number
ebelp TYPE ebelp, " item number of purchasing number
matnr TYPE matnr, " naterial number
menge TYPE bstmg,
" purchase order quantity
netpr TYPE bprei,
"net price in purchase document
END OF ty_ekpo.

DATA : wa_ekpo TYPE ty_ekpo,


it_ekpo TYPE TABLE OF ty_ekpo.
"---------------------EKPO

TYPES : BEGIN OF ty_makt,


matnr TYPE matnr ,
maktx TYPE maktx ,
END OF ty_makt.

" material number


" material description

DATA : wa_makt TYPE ty_makt,


it_makt TYPE TABLE OF ty_makt.
"------------------------MAKT
*************************************************************************
*
selection screen
***********************************************************************
SELECTION-SCREEN BEGIN OF block b1 WITH FRAME TITLE text-111.
DATA v_lifnr TYPE lifnr.
SELECT-OPTIONS :

s_lifnr for v_lifnr.

SELECTION-SCREEN END OF

BLOCK b1.

" at selection screen event


AT SELECTION-SCREEN .
SELECT SINGLE lifnr INTO s_lifnr

" select single using the primary

key
FROM lfa1
WHERE lifnr in s_lifnr.
if sy-subrc <> 0.
MESSAGE I000.
ENDIF.
" now when you are done with input screen and internal table
time to retrive the data from DB
START-OF-SELECTION .
select
lifnr
land1
ort01
anred
INTO TABLE it_lfa1
from
lfa1
WHERE lifnr in s_lifnr.
" end of selection

, its now

if not it_lfa1 IS INITIAL.


LOOP AT it_lfa1 INTO wa_lfa1.
WRITE : /

wa_lfa1-lifnr , wa_lfa1-land1 , wa_lfa1-ort01 , wa_lf

a1-anred .
HIDE : wa_lfa1-lifnr.
" hide is writen after the write statmen
t and it hold the value of sy-lsind
CLEAR wa_lfa1.
ENDLOOP .
ELSE.
MESSAGE I001.
ENDIF.
" top of page
TOP-OF-PAGE .
FORMAT color 2.
WRITE : 'vendor details from the LFA1 table' .
FORMAT COLOR off.
ULINE.
" EVENT at line selection
AT LINE-SELECTION .
case sy-lsind.
when 1.
" display the purchase document details in the 1st seconda
ry list.
SELECT
lifnr
ebeln
bstyp
ekorg
INTO TABLE it_ekko
FROM ekko
WHERE lifnr = wa_lfa1-lifnr. " compared with what data
has been retrived to IT and we need to select that particular records lifnr

if NOT it_ekko IS INITIAL.


loop at it_ekko INTO wa_ekko.
at FIRST .
FORMAT COLOR 4.
WRITE : /3 'vendor no'
cat' , 45 'po org'.
ULINE .
ENDAT.

, 18 'purchase doc no' , 28 'doc

WRITE : / wa_ekko-lifnr UNDER 'vendor no',


wa_ekko-ebeln UNDER 'purchase doc no',
wa_ekko-bstyp UNDER 'doc cat',
wa_ekko-ekorg UNDER 'po org'.
" hide the ebeln to query the next report
HIDE : wa_ekko-ebeln.
CLEAR wa_ekko .
ENDloop.
ELSE.
MESSAGE I001.
ENDIF.

" if no records retrives or not present

WHEN 2.
" display the line item in the secondary list
SELECT
ebeln
ebelp
matnr
menge
netpr
INTO TABLE it_ekpo
FROM ekpo
WHERE
ebeln = wa_ekko-ebeln.
" which has been selected in the
previos list
if it_ekpo is not INITIAL .
" display the puschase doc in the secondary list
LOOP AT it_ekpo INTO wa_ekpo.
at FIRST .
FORMAT color 5.
WRITE : /3 'item number from purchase document from
ekpo'.
FORMAT color off.
ULINE .
WRITE : /3 'pur do no' , 12 'item no' , 21 'material
no' , 35 'quantity' , 65 ' net price'.

ULINE .
ENDAT .
WRITE : / wa_ekpo-ebeln under 'pur do no' ,
wa_ekpo-ebelp UNDER 'item no',
wa_ekpo-matnr UNDER 'material no' ,
wa_ekpo-menge UNDER 'quantity' LEFTJUSTIFIED ,
wa_ekpo-netpr UNDER 'net price' LEFTJUSTIFIED.
" now hide the material number
HIDE : wa_ekpo-matnr.
CLEAR wa_ekpo.
ENDLOOP .
ELSE .
MESSAGE I001.
ENDIF .
WHEN 3.
" display the details in the 3rd list.
SELECT
matnr
maktx
INTO TABLE it_makt
from makt
WHERE matnr = wa_ekpo-matnr.
if it_makt is NOT INITIAL .
LOOP AT it_makt INTO wa_makt.
at FIRST .
FORMAT color 7.
WRITE : / 'material number and description'.
FORMAT color off.
ULINE .
ENDAT.
WRITE : / wa_makt-matnr , wa_makt-maktx
CLEAR wa_makt.
ENDLOOP .
ELSE.
MESSAGE I001.

ENDIF.
endcase.