Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Logic on the Movement types. 101 and 102... please help me with this Report

Former Member
0 Kudos

Example:

Table MSEG contains these fields

EBELN(Po No) BWART(MovementType) MENGE ( QUANTITY)

MBLNR(GoodsReceiptno)

450000001 101 1000 500000001

450000001 101 200 500000002

450000001 102 1000 500000003

450000001 101 400 500000004

Subtotal : 600

450000002 101 200 500000005

450000002 102 200 500000006

450000002 101 100 500000007

Subtotal : 100

This is the ALV output of my report should be...

I have to develope the report in this way.....i have to Add the quantities of

101 movement type of a particular Purchase order EBELN and should subtract it from the

102 movement type quanity ....Result should be Displayed at the End of every EBELN in a

seperate line......

I have Developed the Report completly......But I just Need the Logic to apply on the Movement types......

My final internal table contains all the fields.....which i have mentioned Above....

If you can help me the Complete Coding...i will be thankful.

please help me seniors.....

Urgent please.....

Thanks,

Nalini

Edited by: nalini sap on Jan 2, 2008 1:52 PM

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

i have modified u r program..plz check it

report a.

TABLES : MSEG , EKBE , MKPF , EKPO ,EKKO, LFA1, T001W.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Tables Declaration Section

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TYPE-POOLS : slis.

DATA : FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

LAYOUT TYPE SLIS_LAYOUT_ALV OCCURS 1 WITH HEADER LINE ,

LCAT TYPE SLIS_FIELDCAT_ALV.

DATA: TOP TYPE slis_t_listheader,

EVENTS TYPE slis_t_event.

DATA : NAME1 LIKE PROJ-POST1,

WERKS LIKE T001W-WERKS.

DATA : T_KEY TYPE SLIS_KEYINFO_ALV.

DATA: It_SORT TYPE SLIS_T_SORTINFO_ALV ."WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Internal Table Definitions

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DATA: BEGIN OF it_mseg,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

MENGE TYPE MSEG-MENGE,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

END OF it_mseg.

DATA: BEGIN OF it_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF it_lfa1.

DATA: BEGIN OF it_ekpo,

ebeln TYPE ekpo-ebeln,

EBELP TYPE EKPO-EBELP,

txz01 TYPE ekpo-txz01,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

END OF it_ekpo.

DATA: BEGIN OF it_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

END OF it_ekko.

DATA: BEGIN OF it_ekbe,

ebeln TYPE ekbe-ebeln,

ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

LFBNR TYPE EKBE-LFBNR,

END OF it_ekbe.

DATA: BEGIN OF it_mkpf,

mblnr TYPE mkpf-mblnr,

mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

budat TYPE mkpf-budat,

xblnr TYPE mkpf-xblnr,

END OF it_mkpf.

DATA: BEGIN OF IT_FINAL,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

MENGE TYPE MSEG-MENGE,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

mengeS TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

RATE(13) TYPE P DECIMALS 2,

VALUE(13) TYPE P DECIMALS 2,

PRICE(13) TYPE P DECIMALS 2,

SUM_101(13) TYPE P DECIMALS 2,

SUM_102(13) TYPE P DECIMALS 2,

sum_sub_tot(13) TYPE P DECIMALS 2,

END OF IT_FINAL.

*data:begin of st_final_display,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

MENGE TYPE MSEG-MENGE,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

mengeS TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

RATE(13) TYPE P DECIMALS 2,

VALUE(13) TYPE P DECIMALS 2,

PRICE(13) TYPE P DECIMALS 2,

SUM_101(13) TYPE P DECIMALS 2,

SUM_102(13) TYPE P DECIMALS 2,

sum_sub_tot(13) TYPE P DECIMALS 2,

index_id type c,

line_color(4) type c,

END OF st_final_display.*

DATA: RATE(12) TYPE P DECIMALS 2.

DATA: VALUE(12) TYPE P DECIMALS 2.

DATA: PRICE(12) TYPE P DECIMALS 2.

DATA: SUM_101(13) TYPE P DECIMALS 2.

DATA: SUM_102(13) TYPE P DECIMALS 2.

DATA: sum_sub_tot(13) TYPE P DECIMALS 2.

*DATA: INDEX_ID TYPE C.

DATA IT_STD_MSEG LIKE TABLE OF IT_MSEG WITH HEADER LINE.

DATA IT_STD_LFA1 LIKE TABLE OF IT_LFA1 WITH HEADER LINE.

DATA IT_STD_EKPO LIKE TABLE OF IT_EKPO WITH HEADER LINE.

DATA IT_STD_EKKO LIKE TABLE OF IT_EKKO WITH HEADER LINE.

DATA IT_STD_EKBE LIKE TABLE OF IT_EKBE WITH HEADER LINE.

DATA IT_STD_MKPF LIKE TABLE OF IT_MKPF WITH HEADER LINE.

DATA IT_STD_FINAL LIKE TABLE OF IT_FINAL WITH HEADER LINE.

DATA it_final_display LIKE TABLE OF st_final_display WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

SELECTION-SCREEN BEGIN OF BLOCK HEADER WITH FRAME TITLE TEXT-001.

PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY,

P_LGORT LIKE MSEG-LGORT ,"OBLIGATORY,

P_EBELN LIKE MSEG-EBELN.

  • * P_EBELN LIKE EKPO-EBELN .

SELECT-OPTIONS: S_MATNR FOR MSEG-MATNR.

SELECT-OPTIONS: S_LIFNR FOR MSEG-LIFNR.

SELECT-OPTIONS: S_MATKL FOR EKPO-MATKL.

SELECT-OPTIONS: S_BEDAT FOR EKKO-BEDAT.

SELECTION-SCREEN END OF BLOCK HEADER.

START-OF-SELECTION.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

START-OF-SELECTION.

PERFORM DATA_RETRIVAL.

PERFORM FIELD.

PERFORM SORT USING IT_SORT.

PERFORM EVENTS USING EVENTS.

PERFORM HEADER USING TOP.

PERFORM LAYOUT.

PERFORM DISPLAY.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * form data_retrival

  • * start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

FORM data_retrival.

SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LGORT LIFNR DMBTR EBELN

EBELP LFPOS LFBNR MENGE PS_PSP_PNR

FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_STD_MSEG

WHERE WERKS = P_WERKS AND LGORT = P_LGORT AND EBELN = P_EBELN AND MATNR IN S_MATNR AND LIFNR IN S_LIFNR.

  • * and ( BWART = '101' OR BWART = '102') .

if sy-subrc = 0.

sort IT_STD_MSEG by lifnr ascending.

SELECT LIFNR NAME1

FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE IT_STD_LFA1 FOR ALL

ENTRIES IN IT_STD_MSEG WHERE LIFNR = IT_STD_MSEG-LIFNR.

if sy-subrc = 0.

sort IT_STD_LFA1 by lifnr ascending.

endif.

sort IT_STD_MSEG by ebeln ebelp matnr werks lgort ascending.

SELECT EBELN EBELP TXZ01 MATNR MENGE WERKS LGORT MATKL NETWR EFFWR

FROM EKPO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKPO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE MATKL IN S_MATKL AND EBELN = IT_STD_MSEG-EBELN AND EBELP =

IT_STD_MSEG-EBELP AND MATNR = IT_STD_MSEG-MATNR

AND WERKS = IT_STD_MSEG-WERKS AND LGORT = IT_STD_MSEG-LGORT.

if sy-subrc = 0.

sort IT_STD_EKPO by ebeln ebelp ascending.

endif.

sort IT_STD_MSEG by ebeln lifnr ascending.

SELECT EBELN BUKRS BSART LIFNR BEDAT

FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKKO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE BEDAT IN S_BEDAT AND BSART = 'NB' AND EBELN =

IT_STD_MSEG-EBELN AND LIFNR = IT_STD_MSEG-LIFNR .

if sy-subrc = 0.

sort IT_STD_EKKO by ebeln ascending.

endif.

sort IT_STD_MSEG by ebeln ebelp lfbnr ascending.

SELECT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI BWART BUDAT XBLNR

LFBNR

FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKBE FOR ALL

ENTRIES IN IT_STD_MSEG WHERE EBELN = IT_STD_MSEG-EBELN

AND EBELP = IT_STD_MSEG-EBELP AND LFBNR = IT_STD_MSEG-LFBNR.

if sy-subrc = 0.

sort IT_STD_MSEG by ebeln ebelp ascending.

endif.

ENDIF.

IF NOT IT_STD_EKBE[] IS INITIAL.

sort IT_STD_EKBE by xblnr budat ascending.

SELECT MBLNR MJAHR BLART BLDAT BUDAT XBLNR

FROM MKPF INTO CORRESPONDING FIELDS OF TABLE IT_STD_MKPF FOR ALL

ENTRIES IN IT_STD_EKBE

WHERE XBLNR = IT_STD_EKBE-XBLNR AND BUDAT = IT_STD_EKBE-BUDAT.

if sy-subrc = 0.

sort IT_STD_MKPF by mblnr mjahr ascending.

ENDIF.

endif.

  • * DATA : VAR(80) TYPE C.

LOOP AT IT_STD_MSEG.

IT_STD_FINAL-MBLNR = IT_STD_MSEG-MBLNR.

IT_STD_FINAL-MJAHR = IT_STD_MSEG-MJAHR.

IT_STD_FINAL-ZEILE = IT_STD_MSEG-ZEILE.

IT_STD_FINAL-BWART = IT_STD_MSEG-BWART.

IT_STD_FINAL-MATNR = IT_STD_MSEG-MATNR.

IT_STD_FINAL-WERKS = IT_STD_MSEG-WERKS.

IT_STD_FINAL-LGORT = IT_STD_MSEG-LGORT.

IT_STD_FINAL-LIFNR = IT_STD_MSEG-LIFNR.

IT_STD_FINAL-DMBTR = IT_STD_MSEG-DMBTR.

IT_STD_FINAL-EBELN = IT_STD_MSEG-EBELN.

IT_STD_FINAL-EBELP = IT_STD_MSEG-EBELP.

IT_STD_FINAL-LFPOS = IT_STD_MSEG-LFPOS.

IT_STD_FINAL-LFBNR = IT_STD_MSEG-LFBNR.

IT_STD_FINAL-MENGE = IT_STD_MSEG-MENGE.

IT_STD_FINAL-PS_PSP_PNR = IT_STD_MSEG-PS_PSP_PNR.

READ TABLE IT_STD_LFA1 WITH KEY LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-NAME1 = IT_STD_LFA1-NAME1.

ENDIF.

READ TABLE IT_STD_EKPO WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

MATNR = IT_STD_FINAL-MATNR

WERKS = IT_STD_FINAL-WERKS

LGORT = IT_STD_FINAL-LGORT.

IF SY-SUBRC = 0.

IT_STD_FINAL-TXZ01 = IT_STD_EKPO-TXZ01.

IT_STD_FINAL-MATKL = IT_STD_EKPO-MATKL.

IT_STD_FINAL-MENGES = IT_STD_EKPO-MENGE.

IT_STD_FINAL-NETWR = IT_STD_EKPO-NETWR.

IT_STD_FINAL-EFFWR = IT_STD_EKPO-EFFWR.

ENDIF.

READ TABLE IT_STD_EKKO WITH KEY EBELN = IT_STD_FINAL-EBELN

LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-BUKRS = IT_STD_EKKO-BUKRS.

IT_STD_FINAL-BSART = IT_STD_EKKO-BSART.

  • * IT_STD_FINAL-LIFNR = IT_STD_EKKO-LIFNR.

IT_STD_FINAL-BEDAT = IT_STD_EKKO-BEDAT.

ENDIF.

READ TABLE IT_STD_EKBE WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

LFBNR = IT_STD_FINAL-LFBNR

BWART = IT_STD_FINAL-BWART.

IF SY-SUBRC = 0.

IT_STD_FINAL-ZEKKN = IT_STD_EKBE-ZEKKN.

IT_STD_FINAL-VGABE = IT_STD_EKBE-VGABE.

IT_STD_FINAL-GJAHR = IT_STD_EKBE-GJAHR.

IT_STD_FINAL-BELNR = IT_STD_EKBE-BELNR.

IT_STD_FINAL-BUZEI = IT_STD_EKBE-BUZEI.

IT_STD_FINAL-BUDAT = IT_STD_EKBE-BUDAT.

IT_STD_FINAL-XBLNR = IT_STD_EKBE-XBLNR.

ENDIF.

READ TABLE IT_STD_MKPF WITH KEY XBLNR = IT_STD_FINAL-XBLNR

BUDAT = IT_STD_FINAL-BUDAT.

IF SY-SUBRC = 0.

IT_STD_FINAL-BLART = IT_STD_MKPF-BLART.

IT_STD_FINAL-BLDAT = IT_STD_MKPF-BLDAT.

  • * IT_STD_FINAL-BUDAT = IT_STD_MKPF-BUDAT.

  • * IT_STD_FINAL-XBLNR = IT_STD_MKPF-XBLNR.

ENDIF.

  • * CONCATENATE IT_STD_FINAL-EBELN IT_STD_FINAL-BEDAT

  • * IT_STD_FINAL-NAME1 INTO IT_STD_FINAL-VAR.

APPEND IT_STD_FINAL.

CLEAR IT_STD_FINAL.

ENDLOOP.

*sort IT_STD_MSEG by ebeln ascending.

data:wk_tot_val type p decimals 0.

loop at IT_STD_MSEG.

at new EBELN.

clear it_final_display.

clear sum_101.

clear sum_102.

clear wk_tot_val.

endat.

move-corresponding IT_STD_MSEG to it_final_display.

APPEND it_final_display.

sum_101 = sum_101 + IT_STD_MSEG-menge.

sum_102 = sum_102 + IT_STD_MSEG-menge.

at end of ebeln.

clear it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-MENGE = wk_tot_val.

it_final_display-index_id = 'X'.

APPEND it_final_display.

endat.

endloop.

it_final_display-line_color = 'C300'.

modify it_final_display transporting line_color where index_id = 'X'.*

**IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE.

  • * LOOP AT IT_STD_FINAL.

*

  • * IF IT_STD_FINAL-BWART = '102'. "102'.

  • IT_STD_FINAL-PLACE = IT_STD_FINAL-MENGE * ( -1 ).

  • * IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE * ( -1 ) .

  • modify it_std_final index sy-tabix transporting MENGE place.

  • * ENDIF.

*MODIFY IT_STD_FINAL.

*

  • *

  • o COLLECT IT_STD_FINAL.

  • * ENDLOOP.

**

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-PRICE = IT_STD_FINAL-MENGE - ( 2 * IT_STD_FINAL-KEEP ).

*MODIFY IT_STD_FINAL.

*ENDLOOP.

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-DEL = IT_STD_FINAL-PRICE + IT_STD_FINAL-KEEP.

*MODIFY IT_STD_FINAL.

*ENDLOOP.

  • * LOOP AT IT_STD_FINAL.

*

  • * IT_STD_FINAL-VALUE = IT_STD_FINAL-EFFWR - IT_STD_FINAL-NETWR.

  • * IT_STD_FINAL-RATE = IT_STD_FINAL-VALUE / IT_STD_FINAL-MENGES.

  • * IT_STD_FINAL-PLACE = IT_STD_FINAL-RATE * IT_STD_FINAL-MENGE.

*

**

*

  • * MODIFY IT_STD_FINAL.

  • * ENDLOOP.

ENDFORM. " DATA_RETRIVAL

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*

  • * form data_retrival

  • * end

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*&----


**& Form FIELD

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form FIELD .

layout-info_fieldname = 'LINE_COLOR'.

LCAT-FIELDNAME = 'LIFNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO NO'.

*LCAT-REF_TABNAME = 'EKPO'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'NAME1'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO DATE'.

*LCAT-REF_TABNAME = 'EKKO'.

*LCAT-SELTEXT_M = ''.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'EBELN'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BEDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'NAME OF THE SUPPLIER'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MATNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'AMOUNT'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'PS_PSP_PNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'TXZ01'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MENGE'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'RECEIVED QTY'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BWART'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BLDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'XBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BUDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

*LCAT-FIELDNAME = 'RATE'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*

*LCAT-FIELDNAME = 'KEEP'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'EBELN'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

*

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BSMNG'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

**LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BALMEN'.

**LCAT-DO_SUM = 'X'.

**MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

**ENDLOOP.

LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'MENGE'.

LCAT-DO_SUM = 'X'.

MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

ENDLOOP.

endform. " FIELD

*

*&----


**& Form DISPLAY

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form DISPLAY .

CLEAR : IT_STD_MSEG , IT_STD_EKBE , IT_STD_MKPF , IT_STD_EKPO , IT_STD_EKKO , IT_STD_LFA1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • * I_INTERFACE_CHECK = ' '

  • * I_BYPASSING_BUFFER = ' '

  • * I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • * I_CALLBACK_PF_STATUS_SET = ' '

  • * I_CALLBACK_USER_COMMAND = ' '

  • * I_CALLBACK_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_END_OF_LIST = ' '

  • * I_STRUCTURE_NAME =

  • * I_BACKGROUND_ID = ' '

  • * I_GRID_TITLE =

  • * I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • * IT_EXCLUDING =

  • * IT_SPECIAL_GROUPS =

IT_SORT = IT_SORT

  • * IT_FILTER =

  • * IS_SEL_HIDE =

  • * I_DEFAULT = 'X'

  • * I_SAVE = ' '

  • * IS_VARIANT =

IT_EVENTS = EVENTS

  • * IT_EVENT_EXIT =

  • * IS_PRINT =

  • * IS_REPREP_ID =

  • * I_SCREEN_START_COLUMN = 0

  • * I_SCREEN_START_LINE = 0

  • * I_SCREEN_END_COLUMN = 0

  • * I_SCREEN_END_LINE = 0

  • * I_HTML_HEIGHT_TOP = 0

  • * I_HTML_HEIGHT_END = 0

  • * IT_ALV_GRAPHICS =

  • * IT_HYPERLINK =

  • * IT_ADD_FIELDCAT =

  • * IT_EXCEPT_QINFO =

  • * IR_SALV_FULLSCREEN_ADAPTER =

  • * IMPORTING

  • * E_EXIT_CAUSED_BY_CALLER =

  • * ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_STD_FINAL[]

  • * 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.

*&----


**& Form EVENTS

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form EVENTS USING P_EVENTS TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

ls_event-name = 'TOP_OF_PAGE'.

ls_event-form = 'TOP_OF_PAGE'.

APPEND ls_event TO P_EVENTS.

endform. " EVENTS

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = TOP.

ENDFORM.

*&----


**& Form HEADER

*&----


*

  • * text

*

*----


*

  • * -->P_TOP text

*

*----


form HEADER using p_top TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

DATA : ASD(180),ASD1(120).

CONCATENATE 'PURCHASE ORDER CHECKLIST FROM : ' S_BEDAT-LOW+6(2) '-'

S_BEDAT-LOW4(2) '-' S_BEDAT-LOW0(4) ' TO . ' S_BEDAT-HIGH+6(2) '-'

S_BEDAT-HIGH4(2) '-' S_BEDAT-HIGH0(4) INTO ASD.

CLEAR:ls_line.

ls_line-typ = 'H'.

ls_line-info = ASD .

APPEND ls_line TO P_TOP.

CLEAR:ls_line.

*SELECT SINGLE NAME1 FROM PROJ INTO NAME1 WHERE WERKS = P_WERKS.

*

*CONCATENATE 'PROJECT : ' POST1 ' DATE :' SY-DATUM6(2) '-' SY-DATUM4(2) '-' SY-DATUM+0(4) INTO ASD1.

*

*

  • * ls_line-typ = 'H'.

  • * ls_line-info = ASD1.

  • * APPEND ls_line TO P_TOP.

SELECT SINGLE NAME1 FROM T001W INTO NAME1 WHERE WERKS = P_WERKS.

CONCATENATE 'PROJECT : ' NAME1 ' DATE :' SY-DATUM+6(2) '-'

SY-DATUM4(2) '-' SY-DATUM0(4) INTO ASD1.

ls_line-typ = 'H'.

ls_line-info = ASD1.

APPEND ls_line TO P_TOP.

endform. " HEADER

*

*&----


**& Form SORT

*&----


*

  • *

  • o text

*

**----


*

  • *

  • o -->P_IT_SORT text

*----


form SORT using p_sort TYPE SLIS_T_SORTINFO_ALV.

DATA : LT_SORT TYPE slis_sortinfo_alv.

LT_SORT-fieldname = 'LIFNR'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

LT_SORT-fieldname = 'NAME1'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'EBELN'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'AMOUNT'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

**LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

endform. " SORT

*&----


**& Form LAYOUT

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form LAYOUT .

LAYOUT-ZEBRA = 'X'.

LAYOUT-INFO_FIELDNAME = 'LINE'.

APPEND LAYOUT." TO LAYOUT.

endform. " LAYOUT

22 REPLIES 22

Former Member
0 Kudos

Hi Nalini

Try this code, i did for Purchase order creation.

Pls reward pts if help.

FUNCTION zrfc_vcs_get_purchaseorder.

*"----


""Local interface:

*" EXPORTING

*" REFERENCE(LV_ENTER_DATE) TYPE SY-DATUM

*" REFERENCE(LV_ENTER_TIME) TYPE SY-UZEIT

*"----


&----


*& Program Name : ZRFC_VCS_GET_PURCHASEORDER *

*& Title : Function Module for getting the PURCHASEORDER *

*& Details *

*& Author : M.Jayasree *

*& Create Date : 17/03/2007 *

*& Logical DB : None *

*& Program Type : FM *

*& SAP Release : 4.6 *

*& Description : This is a program used for retrieving the *

*& PURCHASEORDER Details. *

&----


*& REVISION LOG *

*& *

*& LOG# DATE AUTHOR *

*& -


-


-


*

*& 0000 17/03/2007 Jayasree.M *

*& *

*& *

&----


************************************************************************

  • Tables *

************************************************************************

  • TABLES : bsak,ekkn,likp,rm06e,zvcs_con_config.

************************************************************************

  • Data declarations *

************************************************************************

DATA: lv_suc_date LIKE sy-datum,

lv_suc_time LIKE sy-uzeit,

lv_fileloc TYPE char100,

lv_filename TYPE char100,

lv_date TYPE d,

lv_time TYPE t,

lv_filepath TYPE char100,

lv_error TYPE char100,

lv_fileloc1 TYPE char100,

lv_filename1 TYPE char100,

lv_filepath1 TYPE char100,

lv_value TYPE zvcsconfig-zvalue,

lv_value_h TYPE zvcsconfig-zvalue,

lv_value1 TYPE zvcsconfig-zvalue,

lv_fileloc_d TYPE char100,

lv_filename_d TYPE char100,

lv_filepath_d TYPE char100,

lv_taxamt TYPE bseg-wrbtr,

lv_taxamt_t TYPE bseg-wrbtr,

lv_value_d TYPE zvcsconfig-zvalue,

lv_fileloc_d1 TYPE char100,

lv_filename_d1 TYPE char100,

lv_filepath_d1 TYPE char100,

lv_value_d1 TYPE zvcsconfig-zvalue,

lv_fileloc1_d1 TYPE char100,

lv_filename1_d1 TYPE char100,

lv_filepath1_d1 TYPE char100,

lv_value1_d1 TYPE zvcsconfig-zvalue,

lv_fileloc1_d TYPE char100,

lv_filename1_d TYPE char100,

lv_filepath1_d TYPE string,

lv_value1_d TYPE zvcsconfig-zvalue,

lv_werks TYPE ewerk,

lv_pstyp TYPE pstyp,

lv_brtwr TYPE bbwert,

lv_netwr TYPE netwr,

lv_hwae2 TYPE hwae2,

lv_zbd1p TYPE dzbd1p,

lv_kwert TYPE kwert,

lv_traty TYPE traty,

lv_eknam TYPE eknam,

lv_changenr TYPE cdchangenr,

lv_bukrs TYPE bukrs,

lv_inco1 TYPE inco1,

lv_etenr TYPE etenr,

lv_eindt TYPE eindt,

lv_menge_s TYPE etmen,

lv_aufnr TYPE aufnr,

lv_kostl TYPE kostl,

lv_wmwst TYPE wmwst,

lv_fwzuz TYPE fwzuz,

lv_shzuz TYPE shzuz,

lv_lgort TYPE lgort_d,

lv_erfmg TYPE erfmg,

lv_menge_re TYPE menge_d,

lv_lsmng TYPE lsmng,

lv_erfmg1 TYPE erfmg,

lv_maktx TYPE maktx,

lv_evrtn TYPE evrtn,

lv_wemng TYPE wemng,

lv_menge_b TYPE mc_menge_r,

lv_menge_r TYPE mc_menge_r,

lv_menge_sch TYPE mc_menge_r,

lv_waers_a TYPE waers,

lv_kostl_c TYPE kostl,

lv_lifnr_cc TYPE lifnr,

lv_land1 TYPE land1,

lv_kwert_sct TYPE kwert,

lv_erfmg_r TYPE erfmg,

lv_bwart TYPE bwart,

lv_effwr TYPE effwr,

lv_sum TYPE mc_menge_r,

lv_sum1 TYPE banfn,

lv_matnr_p TYPE matnr,

lv_meins TYPE meins,

lv_erfmg_b TYPE erfmg,

lv_bstyp TYPE bstyp,

lv_flag TYPE c,

lv_count TYPE n,

lv_knumv TYPE ekko-knumv,

lv_waers TYPE ekko-waers,

lv_fwnav TYPE bset-fwste,

lv_kwert_d TYPE kwert,

lv_bdmng TYPE bdmng,

lv_lewed TYPE lewed,

lv_kwert1 TYPE konv-kwert,

lv_kwert2 TYPE konv-kwert,

lv_kwert_3 TYPE konv-kwert,

lv_kwert_total TYPE konv-kwert,

lv_wemng_sc TYPE wemng,

lv_vtext TYPE vtext,

lv_text1 TYPE t007s-text1,

lv_bezei TYPE bezei30,

lv_server TYPE tsle4-server,

lv_land1_t TYPE land1,

lv_kalsm TYPE kalsm,

lv_mwskz TYPE mwskz,

lv_lgobe TYPE lgobe,

lv_zcond1 TYPE zcondition1,

lv_zcond2 TYPE zcondition1,

lv_zcond3 TYPE zcondition1,

lv_zcond4 TYPE zcondition1,

lv_zcond5 TYPE zcondition1,

lv_zcond6 TYPE zcondition1,

lv_zcond7 TYPE zcondition1,

lv_zcond8 TYPE zcondition1,

lv_zcond9 TYPE zcondition1 ,

lv_zcond10 TYPE zcondition1,

lv_zcond1_3 TYPE zcondition1 ,

lv_zcond2_3 TYPE zcondition1,

lv_zcond3_3 TYPE zcondition1,

lv_zcond4_3 TYPE zcondition1,

lv_zcond5_3 TYPE zcondition1,

lv_zcond6_3 TYPE zcondition1,

lv_zcond7_3 TYPE zcondition1,

lv_zcond8_3 TYPE zcondition1,

lv_zcond9_3 TYPE zcondition1 ,

lv_zcond10_3 TYPE zcondition1,

lv_bukrs_t TYPE bukrs,

lv_waers_t TYPE waers,

lv_fwnav_t TYPE bset-fwste,

lv_tax TYPE netwr,

lv_erfmg_r_e TYPE erfmg,

lv_erfmg_acc1 TYPE erfmg,

lv_erfmg_acc2 TYPE erfmg,

lv_erfmg_acc3 TYPE erfmg,

lv_year1(4),

lv_mth1(2),

lv_day1(2),

lv_year(4),

lv_mth(2),

lv_day(2),

lv_char(22),

lv_sign(1) TYPE c,

lv_value_s(21) TYPE c,

lv_ebeln_po TYPE ebeln,

lv_day_v(2),

lv_mth_v(2),

lv_year_v(4),

lv_base TYPE waers,

lv_ebeln_rev TYPE mblnr,

lv_ekpo_elikz TYPE ekpo-elikz,

lv_kwert_dis TYPE konv-kwert,

lv_kwert_dis1 TYPE konv-kwert,

lv_kwert_dis7 TYPE konv-kwert,

lv_zcond1_7 TYPE zcondition1,

lv_zcond2_7 TYPE zcondition1,

lv_zcond3_7 TYPE zcondition1,

lv_zcond4_7 TYPE zcondition1,

lv_zcond5_7 TYPE zcondition1,

lv_zcond6_7 TYPE zcondition1,

lv_zcond7_7 TYPE zcondition1 ,

lv_zcond8_7 TYPE zcondition1,

lv_zcond9_7 TYPE zcondition1,

lv_zcond10_7 TYPE zcondition1,

lv_sign1(1) TYPE c,

lv_value_s1(33) TYPE c,

lv_char1(34) TYPE c,

lv_knumv_d TYPE ekko-knumv,

lv_netwr_t TYPE ekpo-netwr .

************************************************************************

  • Structures *

************************************************************************

    • Structures for storing the output HEADER file

TYPES: BEGIN OF t_fintab1,

ebeln(20) TYPE c, "PONumber

changenr(38) TYPE c, "POAmendmentNumber

server(100) TYPE c, "ERPSource

lifnr(22) TYPE c, "SupplierCode

werks(20) TYPE c, "AddressCode

waers(3) TYPE c, "CurrencyCode

wkurs(34) TYPE c, "ExchRateValue

statu(15) TYPE c, "POHeaderStatus

aedat(20) TYPE c, "PODate

kdatb(20) TYPE c, "ValidFromDate

kdate(20) TYPE c, "ValidToDate

lifnr_b(20) TYPE c, "BillingAddressId

zterm(100) TYPE c, "PaymentTermCode

zbd1t(15) TYPE c, "PaymentTermPeriod

zbd1p(3) TYPE c, "PaymentTermValue

bsart(50) TYPE c, "ContractType

bsart_p(50) TYPE c, "POType

pstyp(50) TYPE c, "POCategory

brtwr(34) TYPE c, "BasicValue

kwert(34) TYPE c, "AdditionalCharges

kwert_t(34) TYPE c, "ThreePLCharges

netwr(34) TYPE c, "TotalPOCost

traty(20) TYPE c, "TransportMode

ekgrp(22) TYPE c, "BuyerCode

eknam(240) TYPE c, "BuyerName

base(3) TYPE c, "BaseCurrencyCode

END OF t_fintab1.

    • Structures for storing the output LINE ITEM file

TYPES: BEGIN OF t_fintab2,

ebelp(38) TYPE c, "POLineNumber

ebeln(20) TYPE c, "PONumber

changenr(38) TYPE c, "POAmendmentNumber

etenr(38) TYPE c, "ScheduleNumber

server(100) TYPE c, "ERPSource

matnr(40) TYPE c, "PartNumber

txz01(240) TYPE c, "PartDescription

kostl_cc(22) TYPE c, "CostCenterCode

bukrs(15) TYPE c, "CompanyCode

idnlf(150) TYPE c, "SupplierRefPartNumber

maktx(40) TYPE c, "SupplierRefPartDesc

eindt(20) TYPE c, "ScheduleDate

menge(22) TYPE c, "POQty

menge_s(22) TYPE c, "ScheduledQty

meins(25) TYPE c, "UOM

netwr(34) TYPE c, "Cost

netpr(34) TYPE c, "CostPerUOM

mwskz(100) TYPE c, "TaxCode

wmwst(34) TYPE c, "TaxValue

kwert_sct(22) TYPE c, "SupCode - TAX

adr_code(20) TYPE c, "AddressCode

shzuz(34) TYPE c, "DiscountValue

mwskz_v(22) TYPE c, "VATCode

wmwst_v(34) TYPE c, "VATValue

vat_op(1) TYPE c, "VATOption

werks(22) TYPE c, "PlantCode

land1(3) TYPE c, "CountryCode

lgnum(22) TYPE c, "WarehouseCode

uebto(12) TYPE c, "RecieptTolerancePve

untto(12) TYPE c, "RecieptToleranceNve

uebto_p(8) TYPE c, "ReceiptTolerancePercentagePve

untto_p(8) TYPE c, "ReceiptTolerancePercentageNve

inco1(100) TYPE c, "ShippingCommTerms

elikz(161) TYPE c, "POLineItemStatus

at_code(8) TYPE c, "AttributeCode

at_des(150) TYPE c, "AttributeDescription

at_std(22) TYPE c, "AttributeStandard

meins_a(25) TYPE c, "AttributeUOM

uebto_a(8) TYPE c, "AttributeTolerancePve

untto_a(8) TYPE c, "AttributeToleranceNve

erfmg(22) TYPE c, "AcceptedQty

menge_re(22) TYPE c, "RejectedQty

lsmng(22) TYPE c, "ReceivedQty

wemng(22) TYPE c, "ReturnedQty

menge_r(22) TYPE c, "BalanceQty

map(22) TYPE c, "MappedQty

geber(22) TYPE c, "BudgetId

bud_des(40) TYPE c, "BudgetDescription

kostl(22) TYPE c, "ProposalId

END OF t_fintab2.

    • Structures for storing the output CONTRACT file

TYPES: BEGIN OF t_fintab3,

ebelp(38) TYPE c, "POLineNumber

ebeln(20) TYPE c, "PONumber

changenr(38) TYPE c, "POAmendmentNumber

etenr(38) TYPE c, "ScheduleNumber

matnr(40) TYPE c, "InputPartNumber

server(100) TYPE c, "ERPSource

erfmg(22) TYPE c, "IssueQty

meins(25) TYPE c, "UOM

erfmg_i(22) TYPE c, "IssuedQty

erfmg_r(22) TYPE c, "ReceivedQty

erfmg_b(22) TYPE c, "BalanceQty

iss_ty(25) TYPE c, "IssueType

END OF t_fintab3.

    • Structures for table EKKO ( Purchasing Document Header )

TYPES: BEGIN OF t_ekko,

ebeln TYPE ekko-ebeln,

lifnr TYPE ekko-lifnr,

waers TYPE ekko-waers,

wkurs TYPE ekko-wkurs,

memory TYPE ekko-memory,

aedat TYPE ekko-aedat,

bedat TYPE ekko-bedat,

zterm TYPE ekko-zterm,

zbd1t TYPE ekko-zbd1t,

bsart TYPE ekko-bsart,

ekgrp TYPE ekko-ekgrp,

knumv TYPE ekko-knumv,

bukrs TYPE ekko-bukrs,

END OF t_ekko.

    • Structures for table EKPO ( Purchasing Document Item )

TYPES: BEGIN OF t_ekpo,

ebelp TYPE ebelp,

ebeln TYPE ebeln,

matnr TYPE matnr,

txz01 TYPE txz01,

idnlf TYPE idnlf,

menge TYPE bstmg,

meins TYPE bstme,

netwr TYPE netwr,

netpr TYPE netpr,

mwskz TYPE mwskz,

werks TYPE ewerk,

uebto TYPE uebto,

untto TYPE untto,

elikz TYPE elikz,

banfn TYPE banfn,

loekz TYPE loekz,

bstyp TYPE bstyp,

brtwr TYPE brtwr,

ktmng TYPE ktmng,

END OF t_ekpo.

    • Structures for table ekpo ( Purchasing Document Item )

TYPES: BEGIN OF t_ekpo_s,

ebelp TYPE ebelp,

ebeln TYPE ebeln,

menge TYPE bstmg,

END OF t_ekpo_s.

    • Structures for table CDHDR ( Change document header )

TYPES: BEGIN OF t_cdhdr,

objectclas TYPE cdhdr-objectclas,

objectid TYPE cdhdr-objectid,

END OF t_cdhdr.

    • Structures for storing the log file

TYPES: BEGIN OF t_logfile,

desc TYPE char50,

END OF t_logfile.

    • Structures for storing the Rejected Qty

TYPES: BEGIN OF t_bwart,

bwart TYPE bwart,

END OF t_bwart.

    • Structures for storing the Mapped Qty

TYPES: BEGIN OF t_eban,

menge TYPE bamng,

END OF t_eban.

    • Structures for storing the Received Qty

TYPES: BEGIN OF t_erfmg,

erfmg TYPE mseg-erfmg,

END OF t_erfmg.

    • Structures for storing the Basic Value

TYPES: BEGIN OF t_basic,

brtwr TYPE ekpo-brtwr,

END OF t_basic.

    • Structures for storing the Additional Charges

TYPES: BEGIN OF t_add,

kwert TYPE konv-kwert,

END OF t_add.

TYPES: BEGIN OF t_add1,

kwert TYPE konv-kwert,

END OF t_add1.

    • Structures for storing the Schedule Number

TYPES: BEGIN OF t_sched,

ebelp TYPE ekpo-ebelp,

ebeln TYPE ekpo-ebeln,

etenr TYPE eket-etenr,

eindt TYPE eket-eindt,

menge TYPE eket-menge,

END OF t_sched.

    • Structures for storing the Conditions regarding the condition table

TYPES: BEGIN OF t_zcond,

zcond1 TYPE kscha,

zcond2 TYPE kscha,

zcond3 TYPE kscha,

zcond4 TYPE kscha,

zcond5 TYPE kscha,

zcond6 TYPE kscha,

zcond7 TYPE kscha,

zcond8 TYPE kscha,

zcond9 TYPE kscha,

zcond10 TYPE kscha,

END OF t_zcond.

    • Structures for Storing the tax values

TYPES: BEGIN OF t_tax,

brtwr TYPE brtwr,

mwskz TYPE mwskz,

END OF t_tax.

    • Structures for Storing the Reservation/dependent requirements

TYPES: BEGIN OF t_resb,

ebeln TYPE ebeln,

ebelp TYPE ebelp,

matnr TYPE matnr,

meins TYPE meins,

bdmng TYPE bdmng,

END OF t_resb.

************************************************************************

  • Internal tables *

************************************************************************

DATA: i_zrfcinfo LIKE zrfcinfo OCCURS 0 WITH HEADER LINE,

i_cdhdr TYPE TABLE OF t_cdhdr WITH HEADER LINE,

i_fintab1 TYPE TABLE OF t_fintab1 WITH HEADER LINE,

i_fintab2 TYPE TABLE OF t_fintab2 WITH HEADER LINE,

i_fintab3 TYPE TABLE OF t_fintab3 WITH HEADER LINE,

i_logfile TYPE TABLE OF t_logfile WITH HEADER LINE,

i_fintab1_h TYPE TABLE OF t_fintab1 WITH HEADER LINE,

i_fintab2_h TYPE TABLE OF t_fintab2 WITH HEADER LINE,

i_fintab3_h TYPE TABLE OF t_fintab3 WITH HEADER LINE,

i_ekpo_s TYPE TABLE OF t_ekpo_s WITH HEADER LINE,

i_fintab2_s TYPE TABLE OF t_fintab2 WITH HEADER LINE,

i_resb TYPE TABLE OF t_resb WITH HEADER LINE,

i_add TYPE TABLE OF t_add WITH HEADER LINE,

i_add1 TYPE TABLE OF t_add1 WITH HEADER LINE,

i_add_3 TYPE TABLE OF t_add WITH HEADER LINE,

i_zcond TYPE TABLE OF t_zcond WITH HEADER LINE,

i_add_cond TYPE TABLE OF t_add WITH HEADER LINE,

i_tax TYPE TABLE OF t_tax WITH HEADER LINE,

i_basic TYPE TABLE OF t_basic WITH HEADER LINE,

i_erfmg TYPE TABLE OF t_erfmg WITH HEADER LINE,

i_erfmg_re TYPE TABLE OF t_erfmg WITH HEADER LINE,

i_ekpo TYPE TABLE OF t_ekpo WITH HEADER LINE,

i_bwart TYPE TABLE OF t_bwart WITH HEADER LINE,

i_eban TYPE TABLE OF t_eban WITH HEADER LINE,

i_sched TYPE TABLE OF t_sched WITH HEADER LINE,

i_bwart_e TYPE TABLE OF t_bwart WITH HEADER LINE,

i_ekko TYPE TABLE OF t_ekko WITH HEADER LINE,

i_add_7 TYPE TABLE OF t_add1 WITH HEADER LINE.

DATA: BEGIN OF i_mwdat OCCURS 0.

INCLUDE STRUCTURE rtax1u15.

DATA: END OF i_mwdat.

DATA: BEGIN OF i_mwdat_t OCCURS 0.

INCLUDE STRUCTURE rtax1u15.

DATA: END OF i_mwdat_t.

************************************************************************

  • Work areas *

************************************************************************

DATA : wa_zrfcinfo TYPE zrfcinfo.

  • Get the last execution date/time from ZTABLE

  • SELECT *

  • FROM zrfcinfo

  • INTO TABLE i_zrfcinfo

  • WHERE

  • name = 'ZRFC_VCS_GET_PURCHASEORDER' AND

  • status = '1'.

*

    • DESCRIBE TABLE i_zrfcinfo LINES sy-tabix.

*

*

    • Sort the table for retrieving the latest date/time

*

  • SORT i_zrfcinfo BY exc_date DESCENDING exc_time DESCENDING.

*

*

  • READ TABLE i_zrfcinfo INDEX 1.

*

  • IF sy-subrc = 0.

  • lv_suc_date = i_zrfcinfo-exc_date.

  • lv_suc_time = i_zrfcinfo-exc_time.

  • ENDIF.

    • fetch the updated records from the table cdhdr ( Change document

    • header ) between the latest date/time

  • lv_suc_date = '20070529'.

SELECT objectclas

objectid

FROM cdhdr

INTO TABLE i_cdhdr

WHERE

objectclas = 'EINKBELEG' AND

udate GE lv_suc_date AND

utime GE lv_suc_time

AND

( tcode = 'ME21' OR

tcode = 'ME21N' OR

tcode = 'ME22' OR

tcode = 'ME23' OR

tcode = 'ME23N' OR

tcode = 'ME22N' OR

tcode = 'ME31K' OR

tcode = 'ME32K' OR

tcode = 'ME33K' OR

tcode = 'ME31L' OR

tcode = 'ME32L' OR

tcode = 'ME33L' OR

tcode = 'ME38' ).

*

************************************************************************

******

    • HEADER

IF NOT i_cdhdr[] IS INITIAL.

    • Retrieve from table EKKO ( Purchasing Document Header )

SELECT ebeln

lifnr

waers

wkurs

memory

aedat

bedat

zterm

zbd1t

bsart

ekgrp

knumv

bukrs

FROM ekko

INTO TABLE i_ekko

FOR ALL ENTRIES IN i_cdhdr

WHERE ebeln = i_cdhdr-objectid+0(10).

ENDIF.

    • Retrieve the Server Name from table TSLE4 ( Instances operating

    • Systems ).

SELECT SINGLE server INTO lv_server FROM tsle4.

    • Appending all the fields to the output HEADER file layout.

    • Loop at i_ekko TABLE ( Purchasing Document Header ).

LOOP AT i_ekko.

MOVE-CORRESPONDING i_ekko TO i_fintab1.

i_fintab1-server = lv_server.

i_fintab1-bsart_p = i_ekko-bsart.

MOVE i_ekko-wkurs TO i_fintab1-wkurs .

CONDENSE i_fintab1-wkurs NO-GAPS.

i_fintab1-lifnr_b = i_ekko-lifnr.

i_fintab1-statu = i_ekko-memory.

i_fintab1-zbd1t = 'DAYS'.

MOVE i_ekko-zbd1t TO i_fintab1-zbd1p .

CONDENSE i_fintab1-zbd1p NO-GAPS.

lv_year = i_ekko-bedat+0(4).

lv_mth = i_ekko-bedat+4(2).

lv_day = i_ekko-bedat+6(2).

lv_year1 = i_ekko-aedat+0(4).

lv_mth1 = i_ekko-aedat+4(2).

lv_day1 = i_ekko-aedat+6(2).

CONCATENATE lv_day1 '/' lv_mth1 '/' lv_year1 INTO i_fintab1-aedat .

CONCATENATE lv_day '/' lv_mth '/' lv_year INTO i_fintab1-kdatb .

*******for Status

  • New Code for determing the Status

  • Check whether you have atlease one undeleted record

SELECT SINGLE elikz INTO lv_ekpo_elikz FROM

ekpo WHERE ebeln = i_ekko-ebeln AND loekz = ' '.

  • If there is an undeleted record

IF sy-subrc = 0.

  • Examine the Delivery Completed Field for all the Items. Even if

  • there is one Not Completed, the PO Header Status will be

  • NotCompleted.

SELECT SINGLE elikz INTO lv_ekpo_elikz FROM

ekpo WHERE ebeln = i_ekko-ebeln AND elikz NE 'X'.

IF sy-subrc = 0.

i_fintab1-statu = 'NotCompleted '.

ELSE.

i_fintab1-statu = 'Completed'.

ENDIF.

ELSE.

i_fintab1-statu = 'Deleted'.

ENDIF.

    • Retrieve the base currency code from table T001.

CLEAR : lv_base.

SELECT SINGLE waers INTO lv_base FROM t001 WHERE bukrs = i_ekko-bukrs

.

IF sy-subrc = 0.

i_fintab1-base = lv_base.

ENDIF.

    • Retrieve the basic value from table ekpo ( Purchasing Document Item )

SELECT brtwr INTO TABLE i_basic FROM ekpo

WHERE ebeln = i_ekko-ebeln AND loekz NE 'L'.

    • Looping at table i_basic for retrieving the basic value

LOOP AT i_basic.

lv_brtwr = lv_brtwr + i_basic-brtwr.

ENDLOOP.

MOVE lv_brtwr TO i_fintab1-brtwr .

CONDENSE i_fintab1-brtwr NO-GAPS.

      • Retrieve AddressCode, POCategory, ValidToDate from table EKPO (

      • Purchasing Document Item )

SELECT SINGLE werks pstyp effwr lewed INTO (lv_werks, lv_pstyp

, lv_effwr , lv_lewed) FROM ekpo WHERE ebeln = i_ekko-ebeln.

IF sy-subrc = 0.

i_fintab1-werks = lv_werks.

i_fintab1-pstyp = lv_pstyp.

IF lv_lewed IS INITIAL.

i_fintab1-kdate = '31/12/9999'.

ELSE.

lv_day_v = lv_lewed+6(2).

lv_mth_v = lv_lewed+4(2).

lv_year_v = lv_lewed+0(4).

CONCATENATE lv_day_v '/' lv_mth_v '/' lv_year_v INTO

i_fintab1-kdate .

ENDIF.

ENDIF.

        • Retrieve Discounts from ZVCS_CON_CONFIG ( CONDITION TABLE )

CLEAR : lv_zcond1_7,

lv_zcond2_7,

lv_zcond3_7,

lv_zcond4_7,

lv_zcond5_7,

lv_zcond6_7,

lv_zcond7_7,

lv_zcond8_7,

lv_zcond9_7,

lv_zcond10_7,

lv_kwert_dis,

i_add_7[].

    • For Condition table

SELECT SINGLE zcond1

zcond2

zcond3

zcond4

zcond5

zcond6

zcond7

zcond8

zcond9

zcond10

FROM zvcs_con_config

INTO (lv_zcond1_7 ,

lv_zcond2_7 ,

lv_zcond3_7 ,

lv_zcond4_7 ,

lv_zcond5_7 ,

lv_zcond6_7 ,

lv_zcond7_7 ,

lv_zcond8_7 ,

lv_zcond9_7 ,

lv_zcond10_7)

WHERE zid = '006' AND zfield = 'DISCOUNTS'.

IF sy-subrc = 0.

    • Retrieve Condition Value from table KONV ( Conditions Transaction

    • Data)

SELECT kwert INTO TABLE i_add_7 FROM konv WHERE knumv =

i_ekko-knumv AND

( ( kschl EQ lv_zcond1_7 ) OR

( kschl EQ lv_zcond2_7 ) OR

( kschl EQ lv_zcond3_7 ) OR

( kschl EQ lv_zcond4_7 ) OR

( kschl EQ lv_zcond5_7 ) OR

( kschl EQ lv_zcond6_7 ) OR

( kschl EQ lv_zcond7_7 ) OR

( kschl EQ lv_zcond8_7 ) OR

( kschl EQ lv_zcond9_7 ) OR

( kschl EQ lv_zcond10_7 ) ).

ENDIF.

    • Looping at i_add_7 table for retrieving the condition value for

    • discount

LOOP AT i_add_7.

lv_kwert_dis = lv_kwert_dis + i_add_7-kwert .

ENDLOOP.

    • Retrieve from table KONV for AdditionalCharges

************

CLEAR : lv_zcond1,

lv_zcond2,

lv_zcond3,

lv_zcond4,

lv_zcond5,

lv_zcond6,

lv_zcond7,

lv_zcond8,

lv_zcond9,

lv_zcond10,

lv_kwert,

i_add[].

    • For Condition table

SELECT SINGLE zcond1

zcond2

zcond3

zcond4

zcond5

zcond6

zcond7

zcond8

zcond9

zcond10

FROM zvcs_con_config

INTO (lv_zcond1 ,

lv_zcond2 ,

lv_zcond3 ,

lv_zcond4 ,

lv_zcond5 ,

lv_zcond6 ,

lv_zcond7 ,

lv_zcond8 ,

lv_zcond9 ,

lv_zcond10)

WHERE zid = '001' AND zfield = 'ADDITIONAL CHARGES'.

IF sy-subrc = 0.

    • Retrieve Condition Value from table KONV ( Conditions Transaction

    • Data)

SELECT kwert INTO TABLE i_add FROM konv

WHERE knumv = i_ekko-knumv AND

( ( kschl EQ lv_zcond1 ) OR

( kschl EQ lv_zcond2 ) OR

( kschl EQ lv_zcond3 ) OR

( kschl EQ lv_zcond4 ) OR

( kschl EQ lv_zcond5 ) OR

( kschl EQ lv_zcond6 ) OR

( kschl EQ lv_zcond7 ) OR

( kschl EQ lv_zcond8 ) OR

( kschl EQ lv_zcond9 ) OR

( kschl EQ lv_zcond10 ) ).

ENDIF.

********************

    • Looping at i_add table for retrieving the condition value for

    • Additional Charges.

LOOP AT i_add.

lv_kwert = lv_kwert + i_add-kwert.

ENDLOOP.

i_fintab1-kwert = lv_kwert.

MOVE lv_kwert TO i_fintab1-kwert .

CONDENSE i_fintab1-kwert NO-GAPS.

    • Retrieve from table KONV for ThreePLCharges

CLEAR : lv_zcond1_3 ,

lv_zcond2_3 ,

lv_zcond3_3 ,

lv_zcond4_3 ,

lv_zcond5_3 ,

lv_zcond6_3 ,

lv_zcond7_3 ,

lv_zcond8_3 ,

lv_zcond9_3 ,

lv_zcond10_3,

lv_kwert_3,

i_add_3[].

************

    • For Condition table

SELECT SINGLE zcond1

zcond2

zcond3

zcond4

zcond5

zcond6

zcond7

zcond8

zcond9

zcond10

FROM zvcs_con_config

INTO (lv_zcond1_3 ,

lv_zcond2_3 ,

lv_zcond3_3 ,

lv_zcond4_3 ,

lv_zcond5_3 ,

lv_zcond6_3 ,

lv_zcond7_3 ,

lv_zcond8_3 ,

lv_zcond9_3 ,

lv_zcond10_3)

WHERE zid = '002' AND zfield = '3PL CHARGES'.

IF sy-subrc = 0.

    • Retrieve Condition Value from table KONV ( Conditions Transaction

    • Data)

SELECT kwert INTO TABLE i_add_3 FROM konv

WHERE knumv = i_ekko-knumv AND

( ( kschl EQ lv_zcond1_3 ) OR

( kschl EQ lv_zcond2_3 ) OR

( kschl EQ lv_zcond3_3 ) OR

( kschl EQ lv_zcond4_3 ) OR

( kschl EQ lv_zcond5_3 ) OR

( kschl EQ lv_zcond6_3 ) OR

( kschl EQ lv_zcond7_3 ) OR

( kschl EQ lv_zcond8_3 ) OR

( kschl EQ lv_zcond9_3 ) OR

( kschl EQ lv_zcond10_3 ) ).

ENDIF.

********************

    • Looping at i_add_7 table for retrieving the condition value for

    • 3 PLCHARGES.

LOOP AT i_add_3.

lv_kwert_3 = lv_kwert_3 + i_add_3-kwert.

ENDLOOP.

i_fintab1-kwert_t = lv_kwert_3.

CONDENSE i_fintab1-kwert_t NO-GAPS.

***********************

    • Calculating the total value

CLEAR : i_zcond,i_add_cond[],

lv_kwert_total.

SELECT zcond1

zcond2

zcond3

zcond4

zcond5

zcond6

zcond7

zcond8

zcond9

zcond10

FROM zvcs_con_config

INTO TABLE i_zcond

WHERE ( zid = '001' ) OR

( zid = '002' ) OR

( zid = '003' ) OR

( zid = '004' ) OR

( zid = '005' ).

    • Looping at i_zcond table for retrieving the condition value for

    • total value

LOOP AT i_zcond.

    • Retrieve Condition Value from table KONV ( Conditions Transaction

    • Data)

SELECT kwert APPENDING TABLE i_add_cond FROM konv

WHERE knumv = i_ekko-knumv AND

( ( kschl EQ i_zcond-zcond1 ) OR

( kschl EQ i_zcond-zcond2 ) OR

( kschl EQ i_zcond-zcond3 ) OR

( kschl EQ i_zcond-zcond4 ) OR

( kschl EQ i_zcond-zcond5 ) OR

( kschl EQ i_zcond-zcond6 ) OR

( kschl EQ i_zcond-zcond7 ) OR

( kschl EQ i_zcond-zcond8 ) OR

( kschl EQ i_zcond-zcond9 ) OR

( kschl EQ i_zcond-zcond10 ) ).

ENDLOOP.

LOOP AT i_add_cond.

lv_kwert_total = lv_kwert_total + i_add_cond-kwert.

ENDLOOP.

    • For Calculating the total value with discount.

lv_kwert_total = lv_kwert_total + lv_kwert_dis.

**********

    • Calculate the tax

CLEAR : i_tax[], lv_tax , lv_taxamt_t, lv_fwnav_t .

    • Retrieve the CompanyCode , CurrencyKey from table EKKO ( PURCHASING

    • DOCUMENT HEADER ).

SELECT SINGLE bukrs waers FROM ekko INTO (lv_bukrs_t , lv_waers_t)

WHERE ebeln = i_ekko-ebeln.

    • Retrieve the Gross order value in PO currency , TaxValue from table

    • EKKO ( PURCHASING DOCUMENT ITEM ).

SELECT brtwr mwskz INTO TABLE i_tax FROM ekpo

WHERE ebeln = i_ekko-ebeln AND loekz NE 'L'.

    • Looping at i_tax table for retrieving the tax value

LOOP AT i_tax.

lv_taxamt_t = i_tax-brtwr + lv_kwert_dis.

IF NOT i_tax-mwskz IS INITIAL.

    • Function for calculating the tax by passing the parameters as

    • lv_bukrs_t ( CompanyCode ), i_tax-mwskz ( taxcode ), lv_waers_t (

    • Currencykey ), lv_taxamt_t ( taxvalue ) for the net

    • amount.

CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT'

EXPORTING

i_bukrs = lv_bukrs_t

i_mwskz = i_tax-mwskz

i_waers = lv_waers_t

i_wrbtr = lv_taxamt_t

IMPORTING

e_fwnav = lv_fwnav_t

TABLES

t_mwdat = i_mwdat_t.

IF sy-subrc <> 0.

ENDIF.

ENDIF.

lv_tax = lv_tax + lv_fwnav_t - lv_kwert_dis.

ENDLOOP.

    • Calculating the TotalPOCost by adding all the values.

lv_netwr_t = lv_kwert_total + i_fintab1-brtwr + lv_tax +

lv_kwert_dis.

MOVE lv_netwr_t TO i_fintab1-netwr.

CLEAR i_add_cond.

CONDENSE i_fintab1-netwr NO-GAPS.

IF i_fintab1-kwert = ' '.

i_fintab1-kwert = '0.0000'.

ENDIF.

    • Retrieve from table T024 ( PurchasingGroup ) for BuyerCode

SELECT SINGLE eknam INTO lv_eknam FROM t024

WHERE ekgrp = i_ekko-ekgrp.

IF sy-subrc = 0.

i_fintab1-eknam = lv_eknam.

ENDIF.

    • Retrieve from table CDHDR ( CHANGE DOCUMENT HEADER ) for

    • POAmendmentNumber

SELECT SINGLE changenr INTO lv_changenr FROM cdhdr

WHERE objectclas = 'EINKBELEG' AND objectid = i_ekko-ebeln.

IF sy-subrc = 0.

i_fintab1-changenr = lv_changenr.

ENDIF.

    • If brtwr (BasicValue) is null then move 0.0000 to this field.

IF i_fintab1-brtwr = ' '.

i_fintab1-brtwr = '0.0000'.

ENDIF.

    • If netwr (TotalPOCost) is null then move 0.0000 to this field.

IF i_fintab1-netwr = ' '.

i_fintab1-netwr = '0.0000'.

ENDIF.

    • Append to the Final Output Table i.e. i_fintab1.

SELECT SINGLE ebeln INTO lv_ebeln_po FROM ekpo

WHERE ebeln = i_ekko-ebeln.

IF sy-subrc = 0.

APPEND i_fintab1.

ENDIF.

CLEAR :

lv_werks,

lv_pstyp,

lv_brtwr,

lv_netwr,

lv_zbd1p,

lv_kwert,

lv_traty,

lv_eknam,

lv_changenr.

CLEAR i_fintab1.

ENDLOOP.

    • Delete final internal table if item category = 7 ( stock transfer ).

DELETE i_fintab1 WHERE pstyp EQ '7'.

************************************************************************

**********

    • LINE ITEM

IF NOT i_cdhdr[] IS INITIAL.

    • Retrieve from table EKPO ( PURCHASING DOCUMENT ITEM ) WHERE

    • ItemCategory Not Equal to 7 ( STOCK TRANSFER ).

SELECT ebelp

ebeln

matnr

txz01

idnlf

menge

meins

netwr

netpr

mwskz

werks

uebto

untto

elikz

banfn

loekz

bstyp

brtwr

ktmng

FROM ekpo

INTO TABLE i_ekpo

FOR ALL ENTRIES IN i_cdhdr

WHERE ebeln = i_cdhdr-objectid+0(10)

AND pstyp NE '7'.

ENDIF.

    • Retrieve the Schedule number

    • Looping at i_ekpo table (PURCHASING DOCUMENT ITEM).

LOOP AT i_ekpo.

    • If Purchasing document category Equals to L ( Scheduling Agreement ).

IF i_ekpo-bstyp EQ 'L'.

    • Retrieve from table eket (Scheduling Agreement Schedule Lines).

SELECT ebelp ebeln etenr eindt menge APPENDING TABLE i_sched FROM

eket

WHERE ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp.

ENDIF.

ENDLOOP.

************

    • Retrieve the Server Name from table TSLE4 ( Instances operating

    • Systems ).

SELECT SINGLE server INTO lv_server FROM tsle4.

    • Appending all the fields to the output LINE file layout

    • Looping at table i_ekpo ( PURCHASING DOCUMENT ITEM )

LOOP AT i_ekpo.

MOVE-CORRESPONDING i_ekpo TO i_fintab2.

***********

    • Retrieve the Company Code from the table ekko (Purchasing Document

    • Header)

SELECT SINGLE bukrs INTO lv_bukrs FROM ekko

WHERE ebeln = i_ekpo-ebeln.

IF sy-subrc = 0.

    • Retrieve the Country Code from table t001 ( Company Codes ).

SELECT SINGLE land1 INTO lv_land1_t FROM t001 WHERE bukrs = lv_bukrs.

IF sy-subrc = 0.

    • Retrieve the kalsm [Procedure (pricing, output control, acct. det.,

    • costing,...)] from table t005 (Countries).

SELECT SINGLE kalsm INTO lv_kalsm FROM t005 WHERE land1 = lv_land1_t.

IF sy-subrc = 0.

    • Retrieve the text1 (Name for value-added tax) from table t007s (Tax

    • Code Names).

SELECT SINGLE text1 INTO lv_text1 FROM t007s WHERE mwskz =

i_ekpo-mwskz

AND spras = 'EN' AND kalsm = lv_kalsm.

IF sy-subrc = 0.

i_fintab2-mwskz = lv_text1.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

i_fintab2-server = lv_server.

i_fintab2-ebelp = i_ekpo+2(3).

i_fintab2-adr_code = 'A1'.

i_fintab2-mwskz_v = i_ekpo-mwskz.

i_fintab2-meins_a = i_ekpo-meins.

i_fintab2-netpr = '1'.

    • If schedule number exists

IF i_ekpo-ktmng = '0'.

MOVE i_ekpo-menge TO i_fintab2-menge.

ELSE.

MOVE i_ekpo-ktmng TO i_fintab2-menge.

ENDIF.

CONDENSE i_fintab2-menge NO-GAPS.

MOVE i_ekpo-netpr TO i_fintab2-netwr.

CONDENSE i_fintab2-netwr NO-GAPS.

CONDENSE i_fintab2-netpr NO-GAPS.

MOVE i_ekpo-uebto TO i_fintab2-uebto.

CONDENSE i_fintab2-uebto NO-GAPS.

MOVE i_ekpo-untto TO i_fintab2-untto.

CONDENSE i_fintab2-untto NO-GAPS.

MOVE i_ekpo-uebto TO i_fintab2-uebto_p.

CONDENSE i_fintab2-uebto_p NO-GAPS.

MOVE i_ekpo-untto TO i_fintab2-untto_p.

CONDENSE i_fintab2-untto_p NO-GAPS.

MOVE i_ekpo-uebto TO i_fintab2-uebto_a.

CONDENSE i_fintab2-uebto_a NO-GAPS.

MOVE i_ekpo-untto TO i_fintab2-untto_a.

CONDENSE i_fintab2-untto_a NO-GAPS.

lv_taxamt = i_ekpo-brtwr.

    • If PO Qty is initial, then Move 0.000 to this field.

IF i_fintab2-menge = ' '.

i_fintab2-menge = '0.000'.

ENDIF.

    • If i_ekpo-loekz (Deletion indicator in purchasing document) is not

    • initial, then POLineItemStatus is 'Deleted' else if deletion

    • indicator in purchasing document is 'X', That means POLineItemStatus

    • is 'Completed' else if Deletion Indicator in Purchasing Document is

    • initial then POLineItemStatus is 'NotCompleted' .

IF NOT i_ekpo-loekz IS INITIAL.

i_fintab2-elikz = 'Deleted'.

ELSEIF i_ekpo-elikz = 'X'.

i_fintab2-elikz = 'Completed'.

ELSEIF i_ekpo-elikz = ' '.

i_fintab2-elikz = 'NotCompleted'.

ENDIF.

    • If netwr (TotalPOCost) is null then move 0.0000 to this field.

IF i_fintab2-netwr = ' '.

i_fintab2-netwr = '0.0000'.

ENDIF.

    • If netpr (CostPerUOM) is null then move 0.0000 to this field.

IF i_fintab2-netpr = ' '.

i_fintab2-netpr = '0.0000'.

ENDIF.

    • Retrieve from table eban (Purchase Requisition) for MappedQty

IF NOT i_ekpo-banfn IS INITIAL.

SELECT menge INTO TABLE i_eban FROM eban

WHERE banfn = i_ekpo-banfn.

    • Looping at table i_eban ( Purchasing Requistion ).

LOOP AT i_eban.

lv_sum1 = lv_sum1 + i_eban-menge.

ENDLOOP.

IF i_ekpo-menge GT lv_sum1.

i_fintab2-map = lv_sum1.

MOVE lv_sum1 TO i_fintab2-map.

CONDENSE i_fintab2-map NO-GAPS.

ELSEIF i_ekpo-menge LT lv_sum1.

i_fintab2-map = i_ekpo-menge.

MOVE i_ekpo-menge TO i_fintab2-map.

CONDENSE i_fintab2-map NO-GAPS.

ELSEIF i_ekpo-menge EQ lv_sum1.

i_fintab2-map = i_ekpo-menge.

MOVE i_ekpo-menge TO i_fintab2-map.

CONDENSE i_fintab2-map NO-GAPS.

ENDIF.

ENDIF.

    • Retrieve from table EKKO (PURCHASING DOCUMENT HEADER) for bukrs

    • (CompanyCode), inco1 (ShippingCommTerms), SupplierCode-TAX.

SELECT SINGLE bukrs inco1 lifnr bstyp knumv waers INTO (lv_bukrs ,

lv_inco1 , lv_lifnr_cc, lv_bstyp , lv_knumv , lv_waers) FROM ekko

WHERE ebeln = i_ekpo-ebeln.

IF sy-subrc = 0.

i_fintab2-bukrs = lv_bukrs.

i_fintab2-inco1 = lv_inco1.

i_fintab2-kwert_sct = lv_lifnr_cc.

ENDIF.

    • Retrieve from table tinct (Customers: Incoterms: Texts) for bezei

    • (Description).

SELECT SINGLE bezei INTO lv_bezei FROM tinct

WHERE inco1 = lv_inco1 AND spras = 'EN'.

IF sy-subrc = 0.

i_fintab2-inco1 = lv_bezei.

ENDIF.

    • Retrieve from table LFA1 [Vendor Master (General Section)] for land1

    • (County code).

SELECT SINGLE land1 INTO lv_land1 FROM lfa1

WHERE lifnr = lv_lifnr_cc.

IF sy-subrc = 0.

i_fintab2-land1 = lv_land1.

ENDIF.

******************************************************************

    • Retrieve from table EKKN (Account Assignment in Purchasing Document)

    • for aufnr (OrderNumber) & kostl (CostCenter).

SELECT SINGLE aufnr kostl INTO (lv_aufnr, lv_kostl) FROM ekkn

WHERE ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp.

IF sy-subrc = 0.

i_fintab2-kostl_cc = lv_kostl.

ENDIF.

    • Retrieve from table EKPO ( PURCHASING DOCUMENT ITEM ) for lgort

    • (storage location).

SELECT SINGLE lgort INTO lv_lgort FROM ekpo

WHERE ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp.

IF sy-subrc = 0.

i_fintab2-lgnum = lv_lgort.

ENDIF.

    • Retrieve from table t001l (Storage Locations) for lgobe (Description

    • of storage location).

SELECT SINGLE lgobe INTO lv_lgobe FROM t001l WHERE lgort = lv_lgort.

IF sy-subrc = 0.

i_fintab2-lgnum = lv_lgobe.

ENDIF.

    • Retrieve for erfmg (Received quantity) from table mseg (Document

    • Segment: Material).

SELECT erfmg INTO TABLE i_erfmg_re FROM mseg WHERE ebeln =

i_ekpo-ebeln

AND ebelp = i_ekpo-ebelp AND shkzg EQ 'S'.

    • Looping at i_erfmg_re for calculating the recieved quantity.

LOOP AT i_erfmg_re.

lv_erfmg = lv_erfmg + i_erfmg_re-erfmg.

MOVE lv_erfmg TO i_fintab2-lsmng.

CONDENSE i_fintab2-lsmng NO-GAPS.

ENDLOOP.

    • If RecievedQuantity is initial, then move 0 to this field.

IF i_fintab2-lsmng = ' '.

i_fintab2-lsmng = '0'.

ENDIF.

    • Retrieve menge (balanced qty) from table ekbe (History per Purchasing

    • Document).

SELECT SINGLE menge INTO lv_menge_r FROM ekbe

WHERE ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp

AND bewtp = 'E' AND shkzg NE 'S'.

    • Retrieve from table MSEG (Document Segment: Material) for bwart

    • (Movement type).

SELECT bwart INTO TABLE i_bwart FROM mseg WHERE ebeln = i_ekpo-ebeln

AND ebelp = i_ekpo-ebelp.

    • Read table i_bwart(movement type) with movement type = 122 ( Return

    • to Vendor).

READ TABLE i_bwart WITH KEY bwart = '122'.

IF sy-subrc = 0.

    • Retrieve erfmg (Quantity in unit of entry) from table mseg (Document

    • Segment: Material) where movement type = 122.

SELECT erfmg INTO TABLE i_erfmg FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '122'.

    • Looping for table i_erfmg (quantity) for calculating the Returned

    • Quantity but movement type = 122.

LOOP AT i_erfmg.

lv_erfmg_r = lv_erfmg_r + i_erfmg-erfmg.

MOVE lv_erfmg_r TO i_fintab2-wemng.

CONDENSE i_fintab2-wemng NO-GAPS.

ENDLOOP.

ENDIF.

    • Read table i_bwart (movement type) with movement type = 124 (

    • Returned Blocked Stock).

READ TABLE i_bwart WITH KEY bwart = '124'.

IF sy-subrc = 0.

    • Retrieve Returned Quantity from table mseg (Document

    • Segment: Material) where movement type = 124.

SELECT SINGLE erfmg INTO lv_erfmg_r FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '124'.

IF sy-subrc = 0.

i_fintab2-wemng = lv_erfmg_r.

MOVE lv_erfmg_r TO i_fintab2-wemng.

CONDENSE i_fintab2-wemng NO-GAPS.

ENDIF.

ENDIF.

    • Read table i_bwart (movement type) with movement type = 161 (

    • GR Returns).

READ TABLE i_bwart WITH KEY bwart = '161'.

IF sy-subrc = 0.

    • Retrieve Returned Quantity from table mseg (Document

    • Segment: Material) where movement type = 161.

SELECT SINGLE erfmg INTO lv_erfmg_r FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '161'.

IF sy-subrc = 0.

i_fintab2-wemng = lv_erfmg_r.

MOVE lv_erfmg_r TO i_fintab2-wemng.

CONDENSE i_fintab2-wemng NO-GAPS.

ENDIF.

ENDIF.

    • Retrieve from table MSEG for Rejected Qty

CLEAR : i_bwart_e[],lv_erfmg_r_e.

    • Retrieve from table MSEG (Document Segment: Material) for bwart

    • (Movement type).

SELECT bwart INTO TABLE i_bwart_e FROM mseg WHERE ebeln =

i_ekpo-ebeln

AND ebelp = i_ekpo-ebelp.

    • Read table i_bwart (movement type) with movement type = 102 (

    • GR For PO Reversal).

READ TABLE i_bwart_e WITH KEY bwart = '102'.

IF sy-subrc = 0.

    • Retrieve Rejected Quantity from table mseg (Document

    • Segment: Material) where movement type = 102.

SELECT SINGLE erfmg INTO lv_erfmg_r_e FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '102'.

IF sy-subrc = 0.

i_fintab2-menge_re = lv_erfmg_r_e.

MOVE lv_erfmg_r_e TO i_fintab2-menge_re.

CONDENSE i_fintab2-menge_re NO-GAPS.

ENDIF.

ENDIF.

    • Read table i_bwart (movement type) with movement type = 104 (

    • GR TO Blocked Reversal).

READ TABLE i_bwart_e WITH KEY bwart = '104'.

IF sy-subrc = 0.

    • Retrieve Rejected Quantity from table mseg (Document

    • Segment: Material) where movement type = 104.

SELECT SINGLE erfmg INTO lv_erfmg_r_e FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '104'.

IF sy-subrc = 0.

i_fintab2-menge_re = lv_erfmg_r_e.

MOVE lv_erfmg_r_e TO i_fintab2-menge_re.

CONDENSE i_fintab2-menge_re NO-GAPS.

ENDIF.

ENDIF.

    • Read table i_bwart (movement type) with movement type = 106 (

    • GR From Blocked Reversal).

READ TABLE i_bwart_e WITH KEY bwart = '106'.

IF sy-subrc = 0.

    • Retrieve Rejected Quantity from table mseg (Document

    • Segment: Material) where movement type = 106.

SELECT SINGLE erfmg INTO lv_erfmg_r_e FROM mseg WHERE

ebeln = i_ekpo-ebeln AND ebelp = i_ekpo-ebelp AND bwart = '106'.

IF sy-subrc = 0.

i_fintab2-menge_re = lv_erfmg_r_e.

MOVE lv_erfmg_r_e TO i_fintab2-menge_re.

CONDENSE i_fintab2-menge_re NO-GAPS.

ENDIF.

ENDIF.

    • If Returned Quantity is not Initial.

IF NOT i_fintab2-wemng IS INITIAL.

CLEAR i_fintab2-erfmg.

    • Calculate the Accepted Quantity which is equal to Recieved Quantity

    • - Returned Quantity.

lv_erfmg_acc1 = i_fintab2-lsmng - i_fintab2-wemng.

MOVE lv_erfmg_acc1 TO i_fintab2-erfmg.

CONDENSE i_fintab2-erfmg NO-GAPS.

ENDIF.

    • If Rejected Quantity is not initial.

IF NOT i_fintab2-menge_re IS INITIAL.

CLEAR i_fintab2-erfmg.

    • Calculate the Accepted Quantity which is equal to Recieved Quantity

    • - Rejected Quantity.

lv_erfmg_acc2 = i_fintab2-lsmng - i_fintab2-menge_re.

MOVE lv_erfmg_acc2 TO i_fintab2-erfmg.

CONDENSE i_fintab2-erfmg NO-GAPS.

ENDIF.

    • If Returned Quantity is initial then Move 0 to this field.

IF i_fintab2-wemng = ' '.

i_fintab2-wemng = '0'.

ENDIF.

    • If Rejected Quantity is initial then Move 0 to this field.

IF i_fintab2-menge_re = ' '.

i_fintab2-menge_re = '0'.

ENDIF.

    • For accepted qty

**Accepted Quantity = Received - Returned - Rejected.

lv_erfmg_acc3 = i_fintab2-lsmng - i_fintab2-wemng -

i_fintab2-menge_re.

MOVE lv_erfmg_acc3 TO i_fintab2-erfmg.

CONDENSE i_fintab2-erfmg NO-GAPS.

****Calculating the balance quantity.

lv_menge_b = i_fintab2-menge - i_fintab2-erfmg.

MOVE lv_menge_b TO i_fintab2-menge_r.

CONDENSE i_fintab2-menge_r NO-GAPS.

    • If Balance Quantity is initial, then move 0 to this field.

IF i_fintab2-menge_r = ' '.

i_fintab2-menge_r = '0'.

ENDIF.

IF i_fintab2-menge_r CS '-'.

REPLACE '-' INTO i_fintab2-menge_r WITH ' '.

ENDIF.

    • Retrieve from table CDHDR ( CHANGE DOCUMENT HEADER ) for

    • POAmendmentNumber

SELECT SINGLE changenr INTO lv_changenr FROM cdhdr

WHERE objectclas = 'EINKBELEG' AND objectid = i_ekpo-ebeln.

IF sy-subrc = 0.

i_fintab2-changenr = lv_changenr.

ENDIF.

IF NOT i_ekpo-mwskz IS INITIAL.

    • Function for calculating the tax by passing the parameters as

    • lv_bukrs ( CompanyCode ), i_ekpo-mwskz ( taxcode ), lv_waers (

    • Currencykey ), lv_taxamt_t ( taxvalue ) for the net

    • amount.

CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT'

EXPORTING

i_bukrs = lv_bukrs

i_mwskz = i_ekpo-mwskz

i_waers = lv_waers

i_wrbtr = lv_taxamt

IMPORTING

e_fwast = lv_fwnav

TABLES

t_mwdat = i_mwdat.

IF sy-subrc <> 0.

ENDIF.

ENDIF.

i_fintab2-wmwst = lv_fwnav.

CONDENSE i_fintab2-wmwst NO-GAPS.

******for discount

CLEAR : lv_zcond1_7,

lv_zcond2_7,

lv_zcond3_7,

lv_zcond4_7,

lv_zcond5_7,

lv_zcond6_7,

lv_zcond7_7,

lv_zcond8_7,

lv_zcond9_7,

lv_zcond10_7,

lv_kwert_dis1,

i_add_7[].

    • For Condition table

SELECT SINGLE zcond1

zcond2

zcond3

zcond4

zcond5

zcond6

zcond7

zcond8

zcond9

zcond10

FROM zvcs_con_config

INTO (lv_zcond1_7 ,

lv_zcond2_7 ,

lv_zcond3_7 ,

lv_zcond4_7 ,

lv_zcond5_7 ,

lv_zcond6_7 ,

lv_zcond7_7 ,

lv_zcond8_7 ,

lv_zcond9_7 ,

lv_zcond10_7)

WHERE zid = '006' AND zfield = 'DISCOUNTS'.

IF sy-subrc = 0.

SELECT SINGLE knumv INTO lv_knumv_d FROM ekko WHERE ebeln = i_ekpo-ebeln

.

IF sy-subrc = 0.

SELECT kwert INTO TABLE i_add_7 FROM konv WHERE knumv =

lv_knumv_d AND

( ( kschl EQ lv_zcond1_7 ) OR

( kschl EQ lv_zcond2_7 ) OR

( kschl EQ lv_zcond3_7 ) OR

( kschl EQ lv_zcond4_7 ) OR

( kschl EQ lv_zcond5_7 ) OR

( kschl EQ lv_zcond6_7 ) OR

( kschl EQ lv_zcond7_7 ) OR

( kschl EQ lv_zcond8_7 ) OR

( kschl EQ lv_zcond9_7 ) OR

( kschl EQ lv_zcond10_7 ) ).

ENDIF.

ENDIF.

LOOP AT i_add_7.

lv_kwert_dis1 = lv_kwert_dis1 + i_add_7-kwert.

ENDLOOP.

lv_char1 = lv_kwert_dis1.

lv_sign1 = lv_char1+33(1).

lv_value_s1 = lv_char1+0(33).

REPLACE '-' INTO lv_sign1 WITH ' '.

CONCATENATE lv_sign1 lv_value_s1 INTO i_fintab2-shzuz.

CONDENSE i_fintab2-shzuz NO-GAPS.

    • Appending the final internal table with Schedule number

IF i_ekpo-bstyp NE 'L'.

i_fintab2-etenr = '1'.

    • If Scheduled Quantity is intitial then move 0.000 to this field.

IF i_fintab2-menge_s = ' '.

i_fintab2-menge_s = '0.000'.

ENDIF.

APPEND i_fintab2.

ELSE.

    • If schedule number exists

LOOP AT i_sched WHERE ebelp = i_ekpo-ebelp AND ebeln = i_ekpo-ebeln.

i_fintab2-etenr = i_sched-etenr.

i_fintab2-eindt = i_sched-eindt.

MOVE i_sched-menge TO i_fintab2-menge_s.

CONDENSE i_fintab2-menge_s NO-GAPS.

lv_year1 = i_sched-eindt+0(4).

lv_mth1 = i_sched-eindt+4(2).

lv_day1 = i_sched-eindt+6(2).

CONCATENATE lv_day1 '/' lv_mth1 '/' lv_year1 INTO i_fintab2-eindt.

    • For accepted qty.

CLEAR : i_fintab2-erfmg,i_fintab2-menge_r.

    • Retrieve the Accepted Quantity from table eket (Scheduling Agreement

    • Schedule Lines).

SELECT SINGLE wemng INTO lv_wemng_sc FROM eket

WHERE ebelp = i_sched-ebelp AND ebeln = i_sched-ebeln

AND etenr = i_sched-etenr.

IF sy-subrc = 0.

i_fintab2-erfmg = lv_wemng_sc.

CONDENSE i_fintab2-erfmg NO-GAPS.

ENDIF.

lv_menge_sch = i_sched-menge - lv_wemng_sc .

MOVE lv_menge_sch TO i_fintab2-menge_r.

CONDENSE i_fintab2-menge_r NO-GAPS.

i_fintab2-menge_re = '0'.

          • for recieved qty

**

i_fintab2-lsmng = '0.000'.

i_fintab2-wemng = '0.000'.

APPEND i_fintab2.

CLEAR: lv_wemng_sc, i_sched.

ENDLOOP.

ENDIF.

CLEAR: lv_bukrs,

lv_inco1,

lv_etenr,

lv_eindt,

lv_menge_s,

lv_bwart,

lv_sum,

lv_menge_r,

lv_changenr,

lv_knumv,

lv_kostl,

lv_fwnav,

lv_erfmg,

lv_erfmg_r.

CLEAR i_bwart[].

CLEAR : i_fintab2.

ENDLOOP.

************************************************************************

*********

    • SUBCONTRACT PO

IF NOT i_cdhdr[] IS INITIAL.

    • Retrieve from table EKPO ( PURCHASING DOCUMENT ITEM ).

SELECT ebelp

ebeln

menge

FROM ekpo

INTO TABLE i_ekpo_s

FOR ALL ENTRIES IN i_cdhdr

WHERE ebeln = i_cdhdr-objectid+0(10)

AND pstyp = '3'.

ENDIF.

IF NOT i_ekpo_s[] IS INITIAL.

SELECT ebeln ebelp matnr meins bdmng INTO TABLE i_resb FROM resb FOR

ALL ENTRIES IN i_ekpo_s WHERE ebeln = i_ekpo_s-ebeln

AND ebelp = i_ekpo_s-ebelp.

ENDIF.

    • Retrieve the Server Name from table TSLE4 ( Instances operating

    • Systems ).

SELECT SINGLE server INTO lv_server FROM tsle4.

    • Appending all the fields to the output LINE file layout

LOOP AT i_ekpo_s.

MOVE-CORRESPONDING i_ekpo_s TO i_fintab3.

i_fintab3-ebelp = i_ekpo_s+2(3).

i_fintab3-server = lv_server.

CLEAR : lv_erfmg1.

**********

    • Retrieve from table CDHDR ( CHANGE DOCUMENT HEADER ) for

    • POAmendmentNumber

SELECT SINGLE changenr INTO lv_changenr FROM cdhdr

WHERE objectclas = 'EINKBELEG' AND objectid = i_ekpo_s-ebeln.

IF sy-subrc = 0.

i_fintab3-changenr = lv_changenr.

ENDIF.

    • Retrieve from table EKET (Scheduling Agreement Schedule Lines) for

    • etenr (ScheduleNumber).

SELECT SINGLE etenr INTO lv_etenr FROM eket

WHERE ebeln = i_ekpo_s-ebeln AND ebelp = i_ekpo_s-ebelp.

IF sy-subrc = 0.

i_fintab3-etenr = lv_etenr.

ENDIF.

IF NOT i_resb[] IS INITIAL.

LOOP AT i_resb WHERE ebeln = i_ekpo_s-ebeln

AND ebelp = i_ekpo_s-ebelp.

i_fintab3-ebeln = i_resb-ebeln.

i_fintab3-ebelp = i_resb-ebelp.

i_fintab3-matnr = i_resb-matnr.

i_fintab3-meins = i_resb-meins.

i_fintab3-erfmg = i_resb-bdmng.

CONDENSE i_fintab3-erfmg NO-GAPS.

APPEND i_fintab3.

ENDLOOP.

ENDIF.

CLEAR: lv_etenr,

lv_changenr,

lv_erfmg1.

CLEAR : i_fintab3.

ENDLOOP.

************************************************************************

***********

    • Download for HEADER

    • Get the OUTPUT FILE filepath from the table ZVCSConfig (

    • Configuration table ).

SELECT SINGLE zvalue INTO lv_value FROM zvcsconfig

WHERE zconfigkey = 'Outputpath'.

IF sy-subrc = 0.

lv_fileloc = lv_value.

ENDIF.

lv_date = sy-datum.

lv_time = sy-uzeit.

CONCATENATE 'POHeader_SAP_' lv_date '_' lv_time INTO lv_filename.

CONCATENATE lv_fileloc lv_filename '.txt' INTO lv_filepath.

CONCATENATE 'POHeader_ERROR_' lv_date '_' lv_time INTO lv_filename1.

CONCATENATE lv_fileloc1 lv_filename1 '.txt' INTO lv_filepath1.

************************************************************************

*********

    • Download the output file HEADER to an text format

i_fintab1_h-ebeln = 'PONumber'.

i_fintab1_h-changenr = 'Poamendmentnumber'.

i_fintab1_h-server = 'ERPSource'.

i_fintab1_h-lifnr = 'Suppliercode'.

i_fintab1_h-werks = 'AddressCode'.

i_fintab1_h-waers = 'Cur'.

i_fintab1_h-wkurs = 'ExchangeRateValue'.

i_fintab1_h-statu = 'Poheaderstatus'.

i_fintab1_h-aedat = 'Podate'.

i_fintab1_h-kdatb = 'Validfromdate'.

i_fintab1_h-kdate = 'Validtodate'.

i_fintab1_h-lifnr_b = 'Billingaddressid'.

i_fintab1_h-zterm = 'Paymenttermcode'.

i_fintab1_h-zbd1t = 'Paymenttermperiod'.

i_fintab1_h-zbd1p = 'Paymenttermvalue'.

i_fintab1_h-bsart = 'Contracttype'.

i_fintab1_h-bsart_p = 'Potype'.

i_fintab1_h-pstyp = 'Pocategory'.

i_fintab1_h-brtwr = 'Basicvalue'.

i_fintab1_h-kwert = 'Additionalcharges'.

i_fintab1_h-kwert_t = 'ThreePLCharges'.

i_fintab1_h-netwr = 'Totalpocost'.

i_fintab1_h-traty = 'Transportmode'.

i_fintab1_h-ekgrp = 'Buyercode'.

i_fintab1_h-eknam = 'Buyername'.

i_fintab1_h-base = 'BCu'.

APPEND i_fintab1_h.

************************************************************************

*************

    • DETAIL

    • Get the OUTPUT FILE filepath from the table ZVCSConfig

SELECT SINGLE zvalue INTO lv_value_d FROM zvcsconfig

WHERE zconfigkey = 'Outputpath'.

IF sy-subrc = 0.

lv_fileloc_d = lv_value_d.

ENDIF.

lv_date = sy-datum.

lv_time = sy-uzeit.

CONCATENATE 'POLineItem_SAP_' lv_date '_' lv_time INTO

lv_filename_d.

CONCATENATE lv_fileloc_d lv_filename_d '.txt' INTO lv_filepath_d.

CONCATENATE 'Invwith_POdetail_ERROR_' lv_date '_' lv_time INTO

lv_filename1_d.

CONCATENATE lv_fileloc1_d lv_filename1_d '.txt' INTO lv_filepath1_d.

************************************************************************

*************

      • Download the output file DETAIL to an text format

i_fintab2_h-ebelp = 'Pno'.

i_fintab2_h-ebeln = 'PONumber'.

i_fintab2_h-changenr = 'POAmendmentNumber'.

i_fintab2_h-etenr = 'ScheduleNumber'.

i_fintab2_h-server = 'ERPSource'.

i_fintab2_h-matnr = 'PartNumber'.

i_fintab2_h-txz01 = 'PartDescription'.

i_fintab2_h-kostl_cc = 'CostCenterCode'.

i_fintab2_h-bukrs = 'CCod'.

i_fintab2_h-idnlf = 'SupplierRefPartNumber'.

i_fintab2_h-maktx = 'Su'.

i_fintab2_h-eindt = 'ScheduleDate'.

i_fintab2_h-menge = 'POQty'.

i_fintab2_h-menge_s = 'ScheduledQty'.

i_fintab2_h-meins = 'UOM'.

i_fintab2_h-netwr = 'Cost'.

i_fintab2_h-netpr = 'CostPerUOM'.

i_fintab2_h-mwskz = 'TaxCode'.

i_fintab2_h-wmwst = 'TaxValue'.

i_fintab2_h-kwert_sct = 'SupplierCode'.

i_fintab2_h-adr_code = 'AddressCode'.

i_fintab2_h-shzuz = 'DiscountValue'.

i_fintab2_h-mwskz_v = 'VATCode'.

i_fintab2_h-wmwst_v = 'VATValue'.

i_fintab2_h-vat_op = 'V'.

i_fintab2_h-werks = 'PlantCode'.

i_fintab2_h-land1 = 'CCo'.

i_fintab2_h-lgnum = 'WarehouseCode'.

i_fintab2_h-uebto = 'RecTolerPve'.

i_fintab2_h-untto = 'RecTolerNve'.

i_fintab2_h-uebto_p = 'RTPerPve'.

i_fintab2_h-untto_p = 'RTPerNve'.

i_fintab2_h-inco1 = 'ShippingCommTerms'.

i_fintab2_h-elikz = 'POLineItemStatus'.

i_fintab2_h-at_code = 'AttrCode'.

i_fintab2_h-at_des = 'AttributeDescription'.

i_fintab2_h-at_std = 'AttributeStandard'.

i_fintab2_h-meins_a = 'AttributeUOM'.

i_fintab2_h-uebto_a = 'ATolPve'.

i_fintab2_h-untto_a = 'ATolNve'.

i_fintab2_h-erfmg = 'AcceptedQty'.

i_fintab2_h-menge_re = 'RejectedQty'.

i_fintab2_h-lsmng = 'ReceivedQty'.

i_fintab2_h-wemng = 'ReturnedQty'.

i_fintab2_h-menge_r = 'BalanceQty'.

i_fintab2_h-map = 'MappedQty'.

i_fintab2_h-geber = 'BudgetId'.

i_fintab2_h-bud_des = 'BudgetDescription'.

i_fintab2_h-kostl = 'ProposalId'.

APPEND i_fintab2_h.

************************************************************************

***

    • SUBCONTRACT

    • Get the OUTPUT FILE filepath from the table ZVCSConfig

SELECT SINGLE zvalue INTO lv_value_d1 FROM zvcsconfig

WHERE zconfigkey = 'Outputpath'.

IF sy-subrc = 0.

lv_fileloc_d1 = lv_value_d1.

ENDIF.

CONCATENATE 'POLineItemSubContract_SAP_' lv_date '_' lv_time INTO

lv_filename_d1.

CONCATENATE lv_fileloc_d1 lv_filename_d1 '.txt' INTO lv_filepath_d1.

CONCATENATE 'POLineItemSubContract_ERROR_' lv_date '_' lv_time INTO

lv_filename_d1.

CONCATENATE lv_fileloc_d1 lv_filename_d1 '.txt' INTO lv_filepath1_d1.

************************************************************************

*************

      • Download the output file SUBCONTRACT to an text format

i_fintab3_h-ebelp = 'PLN'.

i_fintab3_h-ebeln = 'PONumber'.

i_fintab3_h-changenr = 'POAmendmentNumber'.

i_fintab3_h-etenr = 'ScheduleNumber'.

i_fintab3_h-matnr = 'InputPartNumber'.

i_fintab3_h-server = 'ERPSource'.

i_fintab3_h-erfmg = 'IssueQty'.

i_fintab3_h-meins = 'UOM'.

i_fintab3_h-erfmg_i = 'IssuedQty'.

i_fintab3_h-erfmg_r = 'ReceivedQty'.

i_fintab3_h-erfmg_b = 'BalanceQty'.

i_fintab3_h-iss_ty = 'IssueType'.

APPEND i_fintab3_h.

************************************************************************

***

CLEAR : lv_flag , lv_count.

    • If the Final internal table is initial.

IF i_fintab1[] IS INITIAL.

      • update the table zrfcinfo with status as '1'

wa_zrfcinfo-name = 'ZRFC_VCS_GET_PURCHASEORDER'.

wa_zrfcinfo-exc_date = sy-datum.

wa_zrfcinfo-exc_time = sy-uzeit.

wa_zrfcinfo-status = '1'.

INSERT zrfcinfo FROM wa_zrfcinfo.

CLEAR wa_zrfcinfo.

EXIT.

ENDIF.

      • For Header

IF NOT i_fintab1[] IS INITIAL.

      • update the table zrfcinfo with status as '1'

wa_zrfcinfo-name = 'ZRFC_VCS_GET_PURCHASEORDER'.

wa_zrfcinfo-exc_date = sy-datum.

wa_zrfcinfo-exc_time = sy-uzeit.

wa_zrfcinfo-status = '1'.

INSERT zrfcinfo FROM wa_zrfcinfo.

CLEAR wa_zrfcinfo.

    • Download into Application server

OPEN DATASET lv_filepath FOR OUTPUT IN TEXT MODE.

*----


    • For System Exceptions

IF sy-subrc NE 0.

MESSAGE e019(zm) WITH lv_filepath1.

EXIT.

ENDIF.

    • End of execptions

*----


SELECT SINGLE zvalue INTO lv_value_h FROM zvcsconfig

WHERE zconfigkey = 'Include Header'.

IF lv_value_h = 'Y'.

LOOP AT i_fintab1_h.

TRANSFER i_fintab1_h TO lv_filepath LENGTH 1021.

ENDLOOP.

ENDIF.

LOOP AT i_fintab1.

TRANSFER i_fintab1 TO lv_filepath LENGTH 1021.

ENDLOOP.

CLOSE DATASET lv_filepath.

**----


    • For Line Item No

    • Download into Application server

OPEN DATASET lv_filepath_d FOR OUTPUT IN TEXT MODE.

*----


    • For System Exceptions

IF sy-subrc NE 0.

MESSAGE e020(zm) WITH lv_filepath1_d.

EXIT.

ENDIF.

    • End of execptions

*----


SELECT SINGLE zvalue INTO lv_value_h FROM zvcsconfig

WHERE zconfigkey = 'Include Header'.

IF lv_value_h = 'Y'.

LOOP AT i_fintab2_h.

TRANSFER i_fintab2_h TO lv_filepath_d LENGTH 1950.

ENDLOOP.

ENDIF.

LOOP AT i_fintab2.

TRANSFER i_fintab2 TO lv_filepath_d LENGTH 1950.

ENDLOOP.

CLOSE DATASET lv_filepath_d.

**----


    • For Subcontract

    • Download into Application server

OPEN DATASET lv_filepath_d1 FOR OUTPUT IN TEXT MODE.

*----


    • For System Exceptions

IF sy-subrc NE 0.

MESSAGE e021(zm) WITH lv_filepath1_d1.

EXIT.

ENDIF.

    • End of execptions

*----


SELECT SINGLE zvalue INTO lv_value_h FROM zvcsconfig

WHERE zconfigkey = 'Include Header'.

IF lv_value_h = 'Y'.

LOOP AT i_fintab3_h.

TRANSFER i_fintab3_h TO lv_filepath_d1 LENGTH 412.

ENDLOOP.

ENDIF.

LOOP AT i_fintab3.

TRANSFER i_fintab3 TO lv_filepath_d1 LENGTH 412.

ENDLOOP.

CLOSE DATASET lv_filepath_d1.

ENDIF.

ENDFUNCTION.

Pls pls reward pts if help.

0 Kudos

The Coding what u have send is more complicated with the Coding what i have Developed .Can u please help with the simple Coding or Logic where i need to Display all the MENGE Quantities from MSEG table and Make the SUBTOTAL....My TEST Data Example is Exact output of My Requirment.....

Ex :450000001 ( 200 + 400 ) - ( 1000 +1000 ) = 600

101 101 101 102

600 should be my total at the end of each EBELN.

thanks

Urgent Please...

nalini.

Former Member
0 Kudos

Hi nalini,

I wrote small program.....might be useful for you...

TABLES : mseg.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE mseg-matnr, "Material Number

menge LIKE mseg-menge, "Quantity

bwart LIKE mseg-bwart, "Movement Type

mblnr LIKE mseg-mblnr, "Document Number

END OF itab.

PARAMETERS : p_werks LIKE mseg-werks .

SELECT-OPTIONS : s_matnr FOR mseg-matnr.

START-OF-SELECTION.

PERFORM get_data.

PERFORM list_display.

&----


*& Form get_data

&----


FORM get_data.

SELECT mseg~matnr mseg~menge mseg~bwart

INTO CORRESPONDING FIELDS OF itab FROM mseg

WHERE mseg~matnr IN s_matnr AND

mseg~werks EQ p_werks AND

( mseg~bwart EQ '101' OR mseg~bwart EQ '102' ).

IF itab-bwart EQ '102'.

itab-menge = itab-menge * -1.

ENDIF.

COLLECT itab.

ENDSELECT.

ENDFORM. "get_data

&----


*& Form LIST_DISPLAY

&----


FORM list_display.

"write your code here for ALV output.

ENDFORM. "LIST_DISPLAY

Former Member
0 Kudos

Hi nalini,

for movemnt types 101 : it means that goods has been moved out of SILO(storage location)

for movemnt types 102 : it means goods have came back (due to defects or anything).

net goods that moved out are :

menge = (total for menge (for movement type 101)) - (total for menge(for movemnt types 102))

hope it solves your problem,

Regards,

Talwinder

kesavadas_thekkillath
Active Contributor
0 Kudos

this is a tricky way.

include a field index_id in the final table.

sort it_mseg by ebeln bwart ascending.

loop at it_mseg.

at new ebeln.

clear itab.

clear sum_101.

clear sum_102.

endat.

move-corresponding it_mseg to itab.

append itab.

sum_101 = sum_101 + it_mseg-menge.

sum_102 = sum_102 + it_mseg-menge.

at end of ebeln.

clear itab.

sum_sub_tot = sum_101 - sum_102.

itab-menge = sum_sub_tot.

itab-index_id = 'X'.

append itab.

endat.

endloop.

while displaying give a color to the row which contains index_id = X

0 Kudos

Hi,

Thanks u very much for ur Responce......this is my exact Coding ...please Can u make it proper According to my Requirment...

please.....i am getting a wrong output....

TABLES : MSEG , EKBE , MKPF , EKPO ,EKKO, LFA1, T001W.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • Tables Declaration Section

  • End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TYPE-POOLS : slis.

DATA : FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

LAYOUT TYPE SLIS_LAYOUT_ALV OCCURS 1 WITH HEADER LINE ,

LCAT TYPE SLIS_FIELDCAT_ALV.

DATA: TOP TYPE slis_t_listheader,

EVENTS TYPE slis_t_event.

DATA : NAME1 LIKE PROJ-POST1,

WERKS LIKE T001W-WERKS.

DATA : T_KEY TYPE SLIS_KEYINFO_ALV.

DATA: It_SORT TYPE SLIS_T_SORTINFO_ALV ."WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • Internal Table Definitions

  • Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DATA: BEGIN OF it_mseg,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

MENGE TYPE MSEG-MENGE,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

END OF it_mseg.

DATA: BEGIN OF it_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF it_lfa1.

DATA: BEGIN OF it_ekpo,

ebeln TYPE ekpo-ebeln,

EBELP TYPE EKPO-EBELP,

txz01 TYPE ekpo-txz01,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

END OF it_ekpo.

DATA: BEGIN OF it_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

END OF it_ekko.

DATA: BEGIN OF it_ekbe,

ebeln TYPE ekbe-ebeln,

ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

LFBNR TYPE EKBE-LFBNR,

END OF it_ekbe.

DATA: BEGIN OF it_mkpf,

mblnr TYPE mkpf-mblnr,

mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

budat TYPE mkpf-budat,

xblnr TYPE mkpf-xblnr,

END OF it_mkpf.

DATA: BEGIN OF IT_FINAL,

ebeln TYPE mseg-ebeln,

MENGE TYPE MSEG-MENGE,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

  • MENGE TYPE MSEG-MENGE,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

  • lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

  • ebeln TYPE ekpo-ebeln,

  • EBELP TYPE EKPO-EBELP,

txz01 TYPE ekpo-txz01,

  • matnr TYPE ekpo-matnr,

  • werks TYPE ekpo-werks,

  • lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

mengeS TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

  • ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

  • lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

  • ebeln TYPE ekbe-ebeln,

  • ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

  • bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

  • LFBNR TYPE EKBE-LFBNR,

  • mblnr TYPE mkpf-mblnr,

  • mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

  • budat TYPE mkpf-budat,

  • xblnr TYPE mkpf-xblnr,

RATE(13) TYPE P DECIMALS 2,

VALUE(13) TYPE P DECIMALS 2,

PRICE(13) TYPE P DECIMALS 2,

SUM_101(13) TYPE P DECIMALS 2,

SUM_102(13) TYPE P DECIMALS 2,

sum_sub_tot(13) TYPE P DECIMALS 2,

  • INDEX_ID TYPE C,

END OF IT_FINAL.

DATA: RATE(12) TYPE P DECIMALS 2.

DATA: VALUE(12) TYPE P DECIMALS 2.

DATA: PRICE(12) TYPE P DECIMALS 2.

DATA: SUM_101(13) TYPE P DECIMALS 2.

DATA: SUM_102(13) TYPE P DECIMALS 2.

DATA: sum_sub_tot(13) TYPE P DECIMALS 2.

*DATA: INDEX_ID TYPE C.

DATA IT_STD_MSEG LIKE TABLE OF IT_MSEG WITH HEADER LINE.

DATA IT_STD_LFA1 LIKE TABLE OF IT_LFA1 WITH HEADER LINE.

DATA IT_STD_EKPO LIKE TABLE OF IT_EKPO WITH HEADER LINE.

DATA IT_STD_EKKO LIKE TABLE OF IT_EKKO WITH HEADER LINE.

DATA IT_STD_EKBE LIKE TABLE OF IT_EKBE WITH HEADER LINE.

DATA IT_STD_MKPF LIKE TABLE OF IT_MKPF WITH HEADER LINE.

DATA IT_STD_FINAL LIKE TABLE OF IT_FINAL WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • Selection-Screen

  • Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

SELECTION-SCREEN BEGIN OF BLOCK HEADER WITH FRAME TITLE TEXT-001.

PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY,

P_LGORT LIKE MSEG-LGORT ,"OBLIGATORY,

P_EBELN LIKE MSEG-EBELN.

  • P_EBELN LIKE EKPO-EBELN .

SELECT-OPTIONS: S_MATNR FOR MSEG-MATNR.

SELECT-OPTIONS: S_LIFNR FOR MSEG-LIFNR.

SELECT-OPTIONS: S_MATKL FOR EKPO-MATKL.

SELECT-OPTIONS: S_BEDAT FOR EKKO-BEDAT.

SELECTION-SCREEN END OF BLOCK HEADER.

START-OF-SELECTION.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • Selection-Screen

  • End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

START-OF-SELECTION.

PERFORM DATA_RETRIVAL.

PERFORM FIELD.

PERFORM SORT USING IT_SORT.

PERFORM EVENTS USING EVENTS.

PERFORM HEADER USING TOP.

PERFORM LAYOUT.

PERFORM DISPLAY.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • form data_retrival

  • start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

FORM data_retrival.

SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LGORT LIFNR DMBTR EBELN

EBELP LFPOS LFBNR MENGE PS_PSP_PNR

FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_STD_MSEG

WHERE WERKS = P_WERKS AND LGORT = P_LGORT AND EBELN = P_EBELN AND MATNR IN S_MATNR AND LIFNR IN S_LIFNR.

  • and ( BWART = '101' OR BWART = '102') .

IF NOT IT_STD_MSEG[] IS INITIAL.

SELECT LIFNR NAME1

FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE IT_STD_LFA1 FOR ALL

ENTRIES IN IT_STD_MSEG WHERE LIFNR = IT_STD_MSEG-LIFNR.

ENDIF.

IF NOT IT_STD_MSEG[] IS INITIAL.

SELECT EBELN EBELP TXZ01 MATNR MENGE WERKS LGORT MATKL NETWR EFFWR

FROM EKPO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKPO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE MATKL IN S_MATKL AND EBELN = IT_STD_MSEG-EBELN AND EBELP =

IT_STD_MSEG-EBELP AND MATNR = IT_STD_MSEG-MATNR

AND WERKS = IT_STD_MSEG-WERKS AND LGORT = IT_STD_MSEG-LGORT.

ENDIF.

IF NOT IT_STD_MSEG[] IS INITIAL.

SELECT EBELN BUKRS BSART LIFNR BEDAT

FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKKO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE BEDAT IN S_BEDAT AND BSART = 'NB' AND EBELN =

IT_STD_MSEG-EBELN AND LIFNR = IT_STD_MSEG-LIFNR .

ENDIF.

IF NOT IT_STD_MSEG[] IS INITIAL.

SELECT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI BWART BUDAT XBLNR

LFBNR

FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKBE FOR ALL

ENTRIES IN IT_STD_MSEG WHERE EBELN = IT_STD_MSEG-EBELN

AND EBELP = IT_STD_MSEG-EBELP AND LFBNR = IT_STD_MSEG-LFBNR.

ENDIF.

IF NOT IT_STD_EKBE[] IS INITIAL.

SELECT MBLNR MJAHR BLART BLDAT BUDAT XBLNR

FROM MKPF INTO CORRESPONDING FIELDS OF TABLE IT_STD_MKPF FOR ALL

ENTRIES IN IT_STD_EKBE

WHERE XBLNR = IT_STD_EKBE-XBLNR AND BUDAT = IT_STD_EKBE-BUDAT.

ENDIF.

  • DATA : VAR(80) TYPE C.

LOOP AT IT_STD_MSEG.

IT_STD_FINAL-MBLNR = IT_STD_MSEG-MBLNR.

IT_STD_FINAL-MJAHR = IT_STD_MSEG-MJAHR.

IT_STD_FINAL-ZEILE = IT_STD_MSEG-ZEILE.

IT_STD_FINAL-BWART = IT_STD_MSEG-BWART.

IT_STD_FINAL-MATNR = IT_STD_MSEG-MATNR.

IT_STD_FINAL-WERKS = IT_STD_MSEG-WERKS.

IT_STD_FINAL-LGORT = IT_STD_MSEG-LGORT.

IT_STD_FINAL-LIFNR = IT_STD_MSEG-LIFNR.

IT_STD_FINAL-DMBTR = IT_STD_MSEG-DMBTR.

IT_STD_FINAL-EBELN = IT_STD_MSEG-EBELN.

IT_STD_FINAL-EBELP = IT_STD_MSEG-EBELP.

IT_STD_FINAL-LFPOS = IT_STD_MSEG-LFPOS.

IT_STD_FINAL-LFBNR = IT_STD_MSEG-LFBNR.

IT_STD_FINAL-MENGE = IT_STD_MSEG-MENGE.

IT_STD_FINAL-PS_PSP_PNR = IT_STD_MSEG-PS_PSP_PNR.

READ TABLE IT_STD_LFA1 WITH KEY LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-NAME1 = IT_STD_LFA1-NAME1.

ENDIF.

READ TABLE IT_STD_EKPO WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

MATNR = IT_STD_FINAL-MATNR

WERKS = IT_STD_FINAL-WERKS

LGORT = IT_STD_FINAL-LGORT.

IF SY-SUBRC = 0.

IT_STD_FINAL-TXZ01 = IT_STD_EKPO-TXZ01.

IT_STD_FINAL-MATKL = IT_STD_EKPO-MATKL.

IT_STD_FINAL-MENGES = IT_STD_EKPO-MENGE.

IT_STD_FINAL-NETWR = IT_STD_EKPO-NETWR.

IT_STD_FINAL-EFFWR = IT_STD_EKPO-EFFWR.

ENDIF.

READ TABLE IT_STD_EKKO WITH KEY EBELN = IT_STD_FINAL-EBELN

LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-BUKRS = IT_STD_EKKO-BUKRS.

IT_STD_FINAL-BSART = IT_STD_EKKO-BSART.

  • IT_STD_FINAL-LIFNR = IT_STD_EKKO-LIFNR.

IT_STD_FINAL-BEDAT = IT_STD_EKKO-BEDAT.

ENDIF.

READ TABLE IT_STD_EKBE WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

LFBNR = IT_STD_FINAL-LFBNR

BWART = IT_STD_FINAL-BWART.

IF SY-SUBRC = 0.

IT_STD_FINAL-ZEKKN = IT_STD_EKBE-ZEKKN.

IT_STD_FINAL-VGABE = IT_STD_EKBE-VGABE.

IT_STD_FINAL-GJAHR = IT_STD_EKBE-GJAHR.

IT_STD_FINAL-BELNR = IT_STD_EKBE-BELNR.

IT_STD_FINAL-BUZEI = IT_STD_EKBE-BUZEI.

IT_STD_FINAL-BUDAT = IT_STD_EKBE-BUDAT.

IT_STD_FINAL-XBLNR = IT_STD_EKBE-XBLNR.

ENDIF.

READ TABLE IT_STD_MKPF WITH KEY XBLNR = IT_STD_FINAL-XBLNR

BUDAT = IT_STD_FINAL-BUDAT.

IF SY-SUBRC = 0.

IT_STD_FINAL-BLART = IT_STD_MKPF-BLART.

IT_STD_FINAL-BLDAT = IT_STD_MKPF-BLDAT.

  • IT_STD_FINAL-BUDAT = IT_STD_MKPF-BUDAT.

  • IT_STD_FINAL-XBLNR = IT_STD_MKPF-XBLNR.

ENDIF.

  • CONCATENATE IT_STD_FINAL-EBELN IT_STD_FINAL-BEDAT

  • IT_STD_FINAL-NAME1 INTO IT_STD_FINAL-VAR.

APPEND IT_STD_FINAL.

CLEAR IT_STD_FINAL.

ENDLOOP.

*include a field KEEP in the final table.

sort IT_STD_MSEG by ebeln bwart ascending.

loop at IT_STD_MSEG.

at new EBELN.

clear IT_STD_MSEG.

clear sum_101.

clear sum_102.

endat.

move-corresponding IT_STD_MSEG to IT_STD_FINAL.

APPEND IT_STD_FINAL.

sum_101 = sum_101 + it_STD_FINAL-menge.

sum_102 = sum_102 + it_STD_FINAL-menge.

at end of ebeln.

clear IT_STD_FINAL.

sum_sub_tot = sum_101 - sum_102.

IT_STD_FINAL-MENGE = sum_sub_tot.

*IT_STD_FINAL-index_id = 'X'.

APPEND IT_STD_FINAL.

endat.

*MODIFY IT_STD_FINAL.

endloop.

**IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE.

  • LOOP AT IT_STD_FINAL.

*

  • IF IT_STD_FINAL-BWART = '102'. "102'.

    • IT_STD_FINAL-PLACE = IT_STD_FINAL-MENGE * ( -1 ).

  • IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE * ( -1 ) .

    • modify it_std_final index sy-tabix transporting MENGE place.

  • ENDIF.

*MODIFY IT_STD_FINAL.

*

    • COLLECT IT_STD_FINAL.

  • ENDLOOP.

**

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-PRICE = IT_STD_FINAL-MENGE - ( 2 * IT_STD_FINAL-KEEP ).

*MODIFY IT_STD_FINAL.

*ENDLOOP.

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-DEL = IT_STD_FINAL-PRICE + IT_STD_FINAL-KEEP.

*MODIFY IT_STD_FINAL.

*ENDLOOP.

  • LOOP AT IT_STD_FINAL.

*

  • IT_STD_FINAL-VALUE = IT_STD_FINAL-EFFWR - IT_STD_FINAL-NETWR.

  • IT_STD_FINAL-RATE = IT_STD_FINAL-VALUE / IT_STD_FINAL-MENGES.

  • IT_STD_FINAL-PLACE = IT_STD_FINAL-RATE * IT_STD_FINAL-MENGE.

*

  • MODIFY IT_STD_FINAL.

  • ENDLOOP.

ENDFORM. " DATA_RETRIVAL

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • form data_retrival

  • end

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

&----


*& Form FIELD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form FIELD .

LCAT-FIELDNAME = 'LIFNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO NO'.

*LCAT-REF_TABNAME = 'EKPO'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'NAME1'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO DATE'.

*LCAT-REF_TABNAME = 'EKKO'.

*LCAT-SELTEXT_M = ''.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'EBELN'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BEDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'NAME OF THE SUPPLIER'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MATNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'AMOUNT'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'PS_PSP_PNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'TXZ01'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MENGE'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'RECEIVED QTY'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BWART'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BLDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'XBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BUDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

*LCAT-FIELDNAME = 'RATE'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*

*LCAT-FIELDNAME = 'KEEP'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'EBELN'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

*

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BSMNG'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

**LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BALMEN'.

**LCAT-DO_SUM = 'X'.

**MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

**ENDLOOP.

LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'MENGE'.

LCAT-DO_SUM = 'X'.

MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

ENDLOOP.

endform. " FIELD

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form DISPLAY .

CLEAR : IT_STD_MSEG , IT_STD_EKBE , IT_STD_MKPF , IT_STD_EKPO , IT_STD_EKKO , IT_STD_LFA1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = IT_SORT

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = EVENTS

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_STD_FINAL[]

  • 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.

&----


*& Form EVENTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form EVENTS USING P_EVENTS TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

ls_event-name = 'TOP_OF_PAGE'.

ls_event-form = 'TOP_OF_PAGE'.

APPEND ls_event TO P_EVENTS.

endform. " EVENTS

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = TOP.

ENDFORM.

&----


*& Form HEADER

&----


  • text

----


  • -->P_TOP text

----


form HEADER using p_top TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

DATA : ASD(180),ASD1(120).

CONCATENATE 'PURCHASE ORDER CHECKLIST FROM : ' S_BEDAT-LOW+6(2) '-'

S_BEDAT-LOW4(2) '-' S_BEDAT-LOW0(4) ' TO . ' S_BEDAT-HIGH+6(2) '-'

S_BEDAT-HIGH4(2) '-' S_BEDAT-HIGH0(4) INTO ASD.

CLEAR:ls_line.

ls_line-typ = 'H'.

ls_line-info = ASD .

APPEND ls_line TO P_TOP.

CLEAR:ls_line.

*SELECT SINGLE NAME1 FROM PROJ INTO NAME1 WHERE WERKS = P_WERKS.

*

*CONCATENATE 'PROJECT : ' POST1 ' DATE :' SY-DATUM6(2) '-' SY-DATUM4(2) '-' SY-DATUM+0(4) INTO ASD1.

*

  • ls_line-typ = 'H'.

  • ls_line-info = ASD1.

  • APPEND ls_line TO P_TOP.

SELECT SINGLE NAME1 FROM T001W INTO NAME1 WHERE WERKS = P_WERKS.

CONCATENATE 'PROJECT : ' NAME1 ' DATE :' SY-DATUM+6(2) '-'

SY-DATUM4(2) '-' SY-DATUM0(4) INTO ASD1.

ls_line-typ = 'H'.

ls_line-info = ASD1.

APPEND ls_line TO P_TOP.

endform. " HEADER

*

*&----


**& Form SORT

*&----


    • text

*----


    • -->P_IT_SORT text

*----


form SORT using p_sort TYPE SLIS_T_SORTINFO_ALV.

DATA : LT_SORT TYPE slis_sortinfo_alv.

LT_SORT-fieldname = 'LIFNR'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

LT_SORT-fieldname = 'NAME1'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'EBELN'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'AMOUNT'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

**LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

endform. " SORT

&----


*& Form LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form LAYOUT .

LAYOUT-ZEBRA = 'X'.

LAYOUT-INFO_FIELDNAME = 'LINE'.

APPEND LAYOUT." TO LAYOUT.

endform. " LAYOUT

thanks,

waiting for ur reply....

Nalini.

0 Kudos

Dear nalini,

First i guess that u have all the data in one internal table before calculations....say itab_final1.

next declare a internal table say ( it_final_display)

with all the fields in itab-final1 and

with two extra fields ( index_id type c , line_color(4) type c )

Then just use this code.

sort itab_final1 by ebeln bwart ascending.

loop at itab_final1.

at new EBELN.

clear it_final_display.

clear sum_101.

clear sum_102.

clear sum_sub_tot.

endat.

move-corresponding itab_final1 to it_final_display.

APPEND it_final_display.

sum_101 = sum_101 + itab_final1-menge.

sum_102 = sum_102 + itab_final1-menge.

at end of ebeln.

clear it_final_display.

sum_sub_tot = sum_101 - sum_102.

it_final_display-MENGE = sum_sub_tot.

it_final_display-index_id = 'X'.

APPEND it_final_display.

endat.

endloop.

it_final_display-line_color = 'C300'.

modify it_final_display transporting line_color where index_id = 'X'.

data:wk_layout type slis_layout_alv.

wk_layout-info_fieldname = 'LINE_COLOR'.

then assign the field catalouge for it_final_display.

then call the alv FM..pass wk_layout as below.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

i_background_id = 'ALV_BACKGROUND'

it_fieldcat = fieldcat[]

is_layout = wk_layout <----


it_events = v_events[]

tables

t_outtab = it_final_list[].

then the line which contains subtotal will display in yellow color

if any problem occurs do revert ...so that i'll try to modify u r code..try it ur self it would be a better practice.

kesavadas_thekkillath
Active Contributor
0 Kudos

i have modified u r program..plz check it

report a.

TABLES : MSEG , EKBE , MKPF , EKPO ,EKKO, LFA1, T001W.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Tables Declaration Section

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TYPE-POOLS : slis.

DATA : FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

LAYOUT TYPE SLIS_LAYOUT_ALV OCCURS 1 WITH HEADER LINE ,

LCAT TYPE SLIS_FIELDCAT_ALV.

DATA: TOP TYPE slis_t_listheader,

EVENTS TYPE slis_t_event.

DATA : NAME1 LIKE PROJ-POST1,

WERKS LIKE T001W-WERKS.

DATA : T_KEY TYPE SLIS_KEYINFO_ALV.

DATA: It_SORT TYPE SLIS_T_SORTINFO_ALV ."WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Internal Table Definitions

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DATA: BEGIN OF it_mseg,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

MENGE TYPE MSEG-MENGE,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

END OF it_mseg.

DATA: BEGIN OF it_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF it_lfa1.

DATA: BEGIN OF it_ekpo,

ebeln TYPE ekpo-ebeln,

EBELP TYPE EKPO-EBELP,

txz01 TYPE ekpo-txz01,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

END OF it_ekpo.

DATA: BEGIN OF it_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

END OF it_ekko.

DATA: BEGIN OF it_ekbe,

ebeln TYPE ekbe-ebeln,

ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

LFBNR TYPE EKBE-LFBNR,

END OF it_ekbe.

DATA: BEGIN OF it_mkpf,

mblnr TYPE mkpf-mblnr,

mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

budat TYPE mkpf-budat,

xblnr TYPE mkpf-xblnr,

END OF it_mkpf.

DATA: BEGIN OF IT_FINAL,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

MENGE TYPE MSEG-MENGE,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

mengeS TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

RATE(13) TYPE P DECIMALS 2,

VALUE(13) TYPE P DECIMALS 2,

PRICE(13) TYPE P DECIMALS 2,

SUM_101(13) TYPE P DECIMALS 2,

SUM_102(13) TYPE P DECIMALS 2,

sum_sub_tot(13) TYPE P DECIMALS 2,

END OF IT_FINAL.

*data:begin of st_final_display,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

MENGE TYPE MSEG-MENGE,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

LFBNR TYPE MSEG-LFBNR,

PS_PSP_PNR TYPE MSEG-PS_PSP_PNR,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

mengeS TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

RATE(13) TYPE P DECIMALS 2,

VALUE(13) TYPE P DECIMALS 2,

PRICE(13) TYPE P DECIMALS 2,

SUM_101(13) TYPE P DECIMALS 2,

SUM_102(13) TYPE P DECIMALS 2,

sum_sub_tot(13) TYPE P DECIMALS 2,

index_id type c,

line_color(4) type c,

END OF st_final_display.*

DATA: RATE(12) TYPE P DECIMALS 2.

DATA: VALUE(12) TYPE P DECIMALS 2.

DATA: PRICE(12) TYPE P DECIMALS 2.

DATA: SUM_101(13) TYPE P DECIMALS 2.

DATA: SUM_102(13) TYPE P DECIMALS 2.

DATA: sum_sub_tot(13) TYPE P DECIMALS 2.

*DATA: INDEX_ID TYPE C.

DATA IT_STD_MSEG LIKE TABLE OF IT_MSEG WITH HEADER LINE.

DATA IT_STD_LFA1 LIKE TABLE OF IT_LFA1 WITH HEADER LINE.

DATA IT_STD_EKPO LIKE TABLE OF IT_EKPO WITH HEADER LINE.

DATA IT_STD_EKKO LIKE TABLE OF IT_EKKO WITH HEADER LINE.

DATA IT_STD_EKBE LIKE TABLE OF IT_EKBE WITH HEADER LINE.

DATA IT_STD_MKPF LIKE TABLE OF IT_MKPF WITH HEADER LINE.

DATA IT_STD_FINAL LIKE TABLE OF IT_FINAL WITH HEADER LINE.

DATA it_final_display LIKE TABLE OF st_final_display WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

SELECTION-SCREEN BEGIN OF BLOCK HEADER WITH FRAME TITLE TEXT-001.

PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY,

P_LGORT LIKE MSEG-LGORT ,"OBLIGATORY,

P_EBELN LIKE MSEG-EBELN.

  • * P_EBELN LIKE EKPO-EBELN .

SELECT-OPTIONS: S_MATNR FOR MSEG-MATNR.

SELECT-OPTIONS: S_LIFNR FOR MSEG-LIFNR.

SELECT-OPTIONS: S_MATKL FOR EKPO-MATKL.

SELECT-OPTIONS: S_BEDAT FOR EKKO-BEDAT.

SELECTION-SCREEN END OF BLOCK HEADER.

START-OF-SELECTION.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

START-OF-SELECTION.

PERFORM DATA_RETRIVAL.

PERFORM FIELD.

PERFORM SORT USING IT_SORT.

PERFORM EVENTS USING EVENTS.

PERFORM HEADER USING TOP.

PERFORM LAYOUT.

PERFORM DISPLAY.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * form data_retrival

  • * start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

FORM data_retrival.

SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LGORT LIFNR DMBTR EBELN

EBELP LFPOS LFBNR MENGE PS_PSP_PNR

FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_STD_MSEG

WHERE WERKS = P_WERKS AND LGORT = P_LGORT AND EBELN = P_EBELN AND MATNR IN S_MATNR AND LIFNR IN S_LIFNR.

  • * and ( BWART = '101' OR BWART = '102') .

if sy-subrc = 0.

sort IT_STD_MSEG by lifnr ascending.

SELECT LIFNR NAME1

FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE IT_STD_LFA1 FOR ALL

ENTRIES IN IT_STD_MSEG WHERE LIFNR = IT_STD_MSEG-LIFNR.

if sy-subrc = 0.

sort IT_STD_LFA1 by lifnr ascending.

endif.

sort IT_STD_MSEG by ebeln ebelp matnr werks lgort ascending.

SELECT EBELN EBELP TXZ01 MATNR MENGE WERKS LGORT MATKL NETWR EFFWR

FROM EKPO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKPO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE MATKL IN S_MATKL AND EBELN = IT_STD_MSEG-EBELN AND EBELP =

IT_STD_MSEG-EBELP AND MATNR = IT_STD_MSEG-MATNR

AND WERKS = IT_STD_MSEG-WERKS AND LGORT = IT_STD_MSEG-LGORT.

if sy-subrc = 0.

sort IT_STD_EKPO by ebeln ebelp ascending.

endif.

sort IT_STD_MSEG by ebeln lifnr ascending.

SELECT EBELN BUKRS BSART LIFNR BEDAT

FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKKO FOR ALL

ENTRIES IN IT_STD_MSEG

WHERE BEDAT IN S_BEDAT AND BSART = 'NB' AND EBELN =

IT_STD_MSEG-EBELN AND LIFNR = IT_STD_MSEG-LIFNR .

if sy-subrc = 0.

sort IT_STD_EKKO by ebeln ascending.

endif.

sort IT_STD_MSEG by ebeln ebelp lfbnr ascending.

SELECT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI BWART BUDAT XBLNR

LFBNR

FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_STD_EKBE FOR ALL

ENTRIES IN IT_STD_MSEG WHERE EBELN = IT_STD_MSEG-EBELN

AND EBELP = IT_STD_MSEG-EBELP AND LFBNR = IT_STD_MSEG-LFBNR.

if sy-subrc = 0.

sort IT_STD_MSEG by ebeln ebelp ascending.

endif.

ENDIF.

IF NOT IT_STD_EKBE[] IS INITIAL.

sort IT_STD_EKBE by xblnr budat ascending.

SELECT MBLNR MJAHR BLART BLDAT BUDAT XBLNR

FROM MKPF INTO CORRESPONDING FIELDS OF TABLE IT_STD_MKPF FOR ALL

ENTRIES IN IT_STD_EKBE

WHERE XBLNR = IT_STD_EKBE-XBLNR AND BUDAT = IT_STD_EKBE-BUDAT.

if sy-subrc = 0.

sort IT_STD_MKPF by mblnr mjahr ascending.

ENDIF.

endif.

  • * DATA : VAR(80) TYPE C.

LOOP AT IT_STD_MSEG.

IT_STD_FINAL-MBLNR = IT_STD_MSEG-MBLNR.

IT_STD_FINAL-MJAHR = IT_STD_MSEG-MJAHR.

IT_STD_FINAL-ZEILE = IT_STD_MSEG-ZEILE.

IT_STD_FINAL-BWART = IT_STD_MSEG-BWART.

IT_STD_FINAL-MATNR = IT_STD_MSEG-MATNR.

IT_STD_FINAL-WERKS = IT_STD_MSEG-WERKS.

IT_STD_FINAL-LGORT = IT_STD_MSEG-LGORT.

IT_STD_FINAL-LIFNR = IT_STD_MSEG-LIFNR.

IT_STD_FINAL-DMBTR = IT_STD_MSEG-DMBTR.

IT_STD_FINAL-EBELN = IT_STD_MSEG-EBELN.

IT_STD_FINAL-EBELP = IT_STD_MSEG-EBELP.

IT_STD_FINAL-LFPOS = IT_STD_MSEG-LFPOS.

IT_STD_FINAL-LFBNR = IT_STD_MSEG-LFBNR.

IT_STD_FINAL-MENGE = IT_STD_MSEG-MENGE.

IT_STD_FINAL-PS_PSP_PNR = IT_STD_MSEG-PS_PSP_PNR.

READ TABLE IT_STD_LFA1 WITH KEY LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-NAME1 = IT_STD_LFA1-NAME1.

ENDIF.

READ TABLE IT_STD_EKPO WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

MATNR = IT_STD_FINAL-MATNR

WERKS = IT_STD_FINAL-WERKS

LGORT = IT_STD_FINAL-LGORT.

IF SY-SUBRC = 0.

IT_STD_FINAL-TXZ01 = IT_STD_EKPO-TXZ01.

IT_STD_FINAL-MATKL = IT_STD_EKPO-MATKL.

IT_STD_FINAL-MENGES = IT_STD_EKPO-MENGE.

IT_STD_FINAL-NETWR = IT_STD_EKPO-NETWR.

IT_STD_FINAL-EFFWR = IT_STD_EKPO-EFFWR.

ENDIF.

READ TABLE IT_STD_EKKO WITH KEY EBELN = IT_STD_FINAL-EBELN

LIFNR = IT_STD_FINAL-LIFNR.

IF SY-SUBRC = 0.

IT_STD_FINAL-BUKRS = IT_STD_EKKO-BUKRS.

IT_STD_FINAL-BSART = IT_STD_EKKO-BSART.

  • * IT_STD_FINAL-LIFNR = IT_STD_EKKO-LIFNR.

IT_STD_FINAL-BEDAT = IT_STD_EKKO-BEDAT.

ENDIF.

READ TABLE IT_STD_EKBE WITH KEY EBELN = IT_STD_FINAL-EBELN

EBELP = IT_STD_FINAL-EBELP

LFBNR = IT_STD_FINAL-LFBNR

BWART = IT_STD_FINAL-BWART.

IF SY-SUBRC = 0.

IT_STD_FINAL-ZEKKN = IT_STD_EKBE-ZEKKN.

IT_STD_FINAL-VGABE = IT_STD_EKBE-VGABE.

IT_STD_FINAL-GJAHR = IT_STD_EKBE-GJAHR.

IT_STD_FINAL-BELNR = IT_STD_EKBE-BELNR.

IT_STD_FINAL-BUZEI = IT_STD_EKBE-BUZEI.

IT_STD_FINAL-BUDAT = IT_STD_EKBE-BUDAT.

IT_STD_FINAL-XBLNR = IT_STD_EKBE-XBLNR.

ENDIF.

READ TABLE IT_STD_MKPF WITH KEY XBLNR = IT_STD_FINAL-XBLNR

BUDAT = IT_STD_FINAL-BUDAT.

IF SY-SUBRC = 0.

IT_STD_FINAL-BLART = IT_STD_MKPF-BLART.

IT_STD_FINAL-BLDAT = IT_STD_MKPF-BLDAT.

  • * IT_STD_FINAL-BUDAT = IT_STD_MKPF-BUDAT.

  • * IT_STD_FINAL-XBLNR = IT_STD_MKPF-XBLNR.

ENDIF.

  • * CONCATENATE IT_STD_FINAL-EBELN IT_STD_FINAL-BEDAT

  • * IT_STD_FINAL-NAME1 INTO IT_STD_FINAL-VAR.

APPEND IT_STD_FINAL.

CLEAR IT_STD_FINAL.

ENDLOOP.

*sort IT_STD_MSEG by ebeln ascending.

data:wk_tot_val type p decimals 0.

loop at IT_STD_MSEG.

at new EBELN.

clear it_final_display.

clear sum_101.

clear sum_102.

clear wk_tot_val.

endat.

move-corresponding IT_STD_MSEG to it_final_display.

APPEND it_final_display.

sum_101 = sum_101 + IT_STD_MSEG-menge.

sum_102 = sum_102 + IT_STD_MSEG-menge.

at end of ebeln.

clear it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-MENGE = wk_tot_val.

it_final_display-index_id = 'X'.

APPEND it_final_display.

endat.

endloop.

it_final_display-line_color = 'C300'.

modify it_final_display transporting line_color where index_id = 'X'.*

**IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE.

  • * LOOP AT IT_STD_FINAL.

*

  • * IF IT_STD_FINAL-BWART = '102'. "102'.

  • IT_STD_FINAL-PLACE = IT_STD_FINAL-MENGE * ( -1 ).

  • * IT_STD_FINAL-KEEP = IT_STD_FINAL-MENGE * ( -1 ) .

  • modify it_std_final index sy-tabix transporting MENGE place.

  • * ENDIF.

*MODIFY IT_STD_FINAL.

*

  • *

  • o COLLECT IT_STD_FINAL.

  • * ENDLOOP.

**

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-PRICE = IT_STD_FINAL-MENGE - ( 2 * IT_STD_FINAL-KEEP ).

*MODIFY IT_STD_FINAL.

*ENDLOOP.

*LOOP AT IT_STD_FINAL.

*IT_STD_FINAL-DEL = IT_STD_FINAL-PRICE + IT_STD_FINAL-KEEP.

*MODIFY IT_STD_FINAL.

*ENDLOOP.

  • * LOOP AT IT_STD_FINAL.

*

  • * IT_STD_FINAL-VALUE = IT_STD_FINAL-EFFWR - IT_STD_FINAL-NETWR.

  • * IT_STD_FINAL-RATE = IT_STD_FINAL-VALUE / IT_STD_FINAL-MENGES.

  • * IT_STD_FINAL-PLACE = IT_STD_FINAL-RATE * IT_STD_FINAL-MENGE.

*

**

*

  • * MODIFY IT_STD_FINAL.

  • * ENDLOOP.

ENDFORM. " DATA_RETRIVAL

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*

  • * form data_retrival

  • * end

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*&----


**& Form FIELD

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form FIELD .

layout-info_fieldname = 'LINE_COLOR'.

LCAT-FIELDNAME = 'LIFNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO NO'.

*LCAT-REF_TABNAME = 'EKPO'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'NAME1'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'PO DATE'.

*LCAT-REF_TABNAME = 'EKKO'.

*LCAT-SELTEXT_M = ''.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'EBELN'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BEDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'NAME OF THE SUPPLIER'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MATNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'AMOUNT'.

LCAT-JUST = 'R'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'PS_PSP_PNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'TXZ01'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MENGE'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'RECEIVED QTY'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BWART'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'MBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BLDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'XBLNR'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

LCAT-FIELDNAME = 'BUDAT'.

LCAT-TABNAME = 'IT_STD_FINAL'.

LCAT-SELTEXT_L = 'VENDOR NO'.

*LCAT-REF_TABNAME = 'LFA1'.

LCAT-JUST = 'L'.

APPEND LCAT TO FIELDCAT.

CLEAR LCAT.

*LCAT-FIELDNAME = 'RATE'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*

*LCAT-FIELDNAME = 'KEEP'.

*LCAT-TABNAME = 'IT_STD_FINAL'.

*LCAT-SELTEXT_L = 'VENDOR NO'.

**LCAT-REF_TABNAME = 'LFA1'.

*LCAT-JUST = 'L'.

*APPEND LCAT TO FIELDCAT.

*CLEAR LCAT.

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'EBELN'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

*

*LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BSMNG'.

*LCAT-DO_SUM = 'X'.

*MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

*ENDLOOP.

*

**LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'BALMEN'.

**LCAT-DO_SUM = 'X'.

**MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

**ENDLOOP.

LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'MENGE'.

LCAT-DO_SUM = 'X'.

MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.

ENDLOOP.

endform. " FIELD

*

*&----


**& Form DISPLAY

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form DISPLAY .

CLEAR : IT_STD_MSEG , IT_STD_EKBE , IT_STD_MKPF , IT_STD_EKPO , IT_STD_EKKO , IT_STD_LFA1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • * I_INTERFACE_CHECK = ' '

  • * I_BYPASSING_BUFFER = ' '

  • * I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • * I_CALLBACK_PF_STATUS_SET = ' '

  • * I_CALLBACK_USER_COMMAND = ' '

  • * I_CALLBACK_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_END_OF_LIST = ' '

  • * I_STRUCTURE_NAME =

  • * I_BACKGROUND_ID = ' '

  • * I_GRID_TITLE =

  • * I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • * IT_EXCLUDING =

  • * IT_SPECIAL_GROUPS =

IT_SORT = IT_SORT

  • * IT_FILTER =

  • * IS_SEL_HIDE =

  • * I_DEFAULT = 'X'

  • * I_SAVE = ' '

  • * IS_VARIANT =

IT_EVENTS = EVENTS

  • * IT_EVENT_EXIT =

  • * IS_PRINT =

  • * IS_REPREP_ID =

  • * I_SCREEN_START_COLUMN = 0

  • * I_SCREEN_START_LINE = 0

  • * I_SCREEN_END_COLUMN = 0

  • * I_SCREEN_END_LINE = 0

  • * I_HTML_HEIGHT_TOP = 0

  • * I_HTML_HEIGHT_END = 0

  • * IT_ALV_GRAPHICS =

  • * IT_HYPERLINK =

  • * IT_ADD_FIELDCAT =

  • * IT_EXCEPT_QINFO =

  • * IR_SALV_FULLSCREEN_ADAPTER =

  • * IMPORTING

  • * E_EXIT_CAUSED_BY_CALLER =

  • * ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_STD_FINAL[]

  • * 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.

*&----


**& Form EVENTS

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form EVENTS USING P_EVENTS TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

ls_event-name = 'TOP_OF_PAGE'.

ls_event-form = 'TOP_OF_PAGE'.

APPEND ls_event TO P_EVENTS.

endform. " EVENTS

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = TOP.

ENDFORM.

*&----


**& Form HEADER

*&----


*

  • * text

*

*----


*

  • * -->P_TOP text

*

*----


form HEADER using p_top TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

DATA : ASD(180),ASD1(120).

CONCATENATE 'PURCHASE ORDER CHECKLIST FROM : ' S_BEDAT-LOW+6(2) '-'

S_BEDAT-LOW4(2) '-' S_BEDAT-LOW0(4) ' TO . ' S_BEDAT-HIGH+6(2) '-'

S_BEDAT-HIGH4(2) '-' S_BEDAT-HIGH0(4) INTO ASD.

CLEAR:ls_line.

ls_line-typ = 'H'.

ls_line-info = ASD .

APPEND ls_line TO P_TOP.

CLEAR:ls_line.

*SELECT SINGLE NAME1 FROM PROJ INTO NAME1 WHERE WERKS = P_WERKS.

*

*CONCATENATE 'PROJECT : ' POST1 ' DATE :' SY-DATUM6(2) '-' SY-DATUM4(2) '-' SY-DATUM+0(4) INTO ASD1.

*

*

  • * ls_line-typ = 'H'.

  • * ls_line-info = ASD1.

  • * APPEND ls_line TO P_TOP.

SELECT SINGLE NAME1 FROM T001W INTO NAME1 WHERE WERKS = P_WERKS.

CONCATENATE 'PROJECT : ' NAME1 ' DATE :' SY-DATUM+6(2) '-'

SY-DATUM4(2) '-' SY-DATUM0(4) INTO ASD1.

ls_line-typ = 'H'.

ls_line-info = ASD1.

APPEND ls_line TO P_TOP.

endform. " HEADER

*

*&----


**& Form SORT

*&----


*

  • *

  • o text

*

**----


*

  • *

  • o -->P_IT_SORT text

*----


form SORT using p_sort TYPE SLIS_T_SORTINFO_ALV.

DATA : LT_SORT TYPE slis_sortinfo_alv.

LT_SORT-fieldname = 'LIFNR'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

LT_SORT-fieldname = 'NAME1'.

LT_SORT-tabname = 'IT_STD_final'.

LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

APPEND LT_SORT TO P_SORT.

CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'EBELN'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

*LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

*

*LT_SORT-fieldname = 'AMOUNT'.

*LT_SORT-tabname = 'IT_STD_final'.

*LT_SORT-up = 'X'.

**LT_SORT-subtot = 'X'.

*APPEND LT_SORT TO P_SORT.

*CLEAR LT_SORT.

endform. " SORT

*&----


**& Form LAYOUT

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


form LAYOUT .

LAYOUT-ZEBRA = 'X'.

LAYOUT-INFO_FIELDNAME = 'LINE'.

APPEND LAYOUT." TO LAYOUT.

endform. " LAYOUT

0 Kudos

Hi Keshu,

I have checked the Edited coding which you had send me.....When i execute...it was not giving the Display off EBELN that is purchase order number ...i Tried to change the Coding Accordingly ...But i was not able to do it....Can you please re check it one....because according to me ..in the place of FORM FIELD section

Display of fields in ALV we have keep Final internal Table .....

Thank You,

Nalini.

0 Kudos

I want to know whether u will pass only one ebeln in the screen

and whether your calculations must be done on EBELP.

0 Kudos

Hi Keshu,

Actually my Report has Selection-Screen WERKS , LGORT, LIFNR

And the OUTPUT fields are LIFNR , NAME1 , EBELN, BEDAT and

MENGE and MBLNR from MSEG Table...which has the Received Quantity with Movement Type 101's and Reversal Quanity 102's....

So for a Particular EBELN in the Output Eg: 4500000001 there are 10,20,30 quantities Received that is 101 Movement types

from the Same EBELN 450000001 there are Reversed Quanity that 10 , 20 that are 102 movement types.....

Now in MSEG MENGE field for the EBELN 450000001 it shows

10 (101) , 20(101) ,10(102) ,20(102) ,30 (102)

So for every EBELN there are Many MBLNR Numbers and for Every MBLNR number Subsequently there will be MENGE Quanities 101 and 102's

This will be Clear when you practically see Fields MBLNR , EBELN, BWART , MENGE.......in MSEG table...OR ME21N Purchase Order History in ME21N

Now My Report Output should be with the fields...

NAME1,EBELN, BEDAT,BWART, MENGE,MBLNR .

My first Sorting is Done on NAME1...Than Sorting Should be Done on EBELN ......

then So there will be 5 different MBLNR numbers and 5 different MENGE Quanities with THREE 101 movement types and TWO 102 Movement types is a random way according to the Date they have Reversed .... for which EBELN,BEDAT will be Same.....According to this Above Example.......

After Sorting EBELN after Each EBELN there should be a Extra Line that is Subtotal Line in which it Should Display MENGE quantity as (101 -102) {( 102030) - (10+20)} = 30 should be the

Subtotal Quanity.......

this Subtotal Should be Done After Each Purchase Order Ends and and New Purchase Order Starts ..

Subtotal should be done on MENGE quanitity for Each EBELN......

I have the Whole Picture of Functionally how it should come but i am Not able to Keep this in the ALV Coding.....

If you want any more Clarification ...please reply me....

waiting for ur reply.....

If you can keep this logic in the Previous Program wat i have send u or give me a Small Smiple Program using MSEG table using this Logic...I will try to Make My report......

Hope u can help me with this...

waiting for ur reply....

thanks,

Nalini

0 Kudos

dear agree now i agree with u...

but check in u r previous posts that selection screen had more entries........plz wait i'll try it now.

0 Kudos

Thank you....

Will be waiting for your reply....

0 Kudos

Hi Keshu,

The Updated Report which you have send is almost Perfect But Only thing is It is Not Calculating the MENGE Quanity Properly.....I was Trying to make it proper..but it is leading me to Different complications.....

Please can u you check is once......

Thanks for you time......

Waiting for ur reply.....

0 Kudos

Oh sorry !!!! corrected

i have marked the problem with * change that table name to

it_std_final

LOOP AT it_std_final.

AT NEW ebeln.

CLEAR it_final_display.

CLEAR sum_101.

CLEAR sum_102.

CLEAR wk_tot_val.

ENDAT.

MOVE-CORRESPONDING it_std_final TO it_final_display.

APPEND it_final_display.

case it_std_mseg-bwart.

when '101'.

sum_101 = sum_101 + it_std_mseg-menge.

when '102'.

sum_102 = sum_102 + it_std_mseg-menge.

endcase.

AT END OF ebeln.

CLEAR it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-menge = wk_tot_val.

it_final_display-LIFNR = 'Sub Total'.

it_final_display-index_id = 'X'.

append it_final_display.

ENDAT.

ENDLOOP.

0 Kudos

Hi Keshu ,

I am almost Done with the Report But i don't Understand...the

lines which i Added New that is Rate and Value is not getting Displayed in the ALV OUTPUT...but in the final internal table that is

it_final_display it is calculating and showing the values....

Please can u check once.....

TABLES : mseg , ekbe , mkpf , ekpo ,ekko, lfa1, t001w.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Tables Declaration Section

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TYPE-POOLS : slis.

DATA : fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

layout TYPE slis_layout_alv OCCURS 1 WITH HEADER LINE ,

lcat TYPE slis_fieldcat_alv.

DATA: top TYPE slis_t_listheader,

events TYPE slis_t_event.

DATA : name1 LIKE proj-post1,

werks LIKE t001w-werks.

DATA : t_key TYPE slis_keyinfo_alv.

DATA: it_sort TYPE slis_t_sortinfo_alv ."WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Internal Table Definitions

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DATA: BEGIN OF it_mseg,

ebeln TYPE mseg-ebeln, "<----place this as first field

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

menge TYPE mseg-menge,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

END OF it_mseg.

DATA: BEGIN OF it_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF it_lfa1.

DATA: BEGIN OF it_ekpo,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

txz01 TYPE ekpo-txz01,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

END OF it_ekpo.

DATA: BEGIN OF it_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

END OF it_ekko.

DATA: BEGIN OF it_ekbe,

ebeln TYPE ekbe-ebeln,

ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

lfbnr TYPE ekbe-lfbnr,

END OF it_ekbe.

DATA: BEGIN OF it_mkpf,

mblnr TYPE mkpf-mblnr,

mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

budat TYPE mkpf-budat,

xblnr TYPE mkpf-xblnr,

END OF it_mkpf.

DATA: BEGIN OF it_final,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

menge TYPE mseg-menge,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

menges TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

rate(13) TYPE p DECIMALS 2,

value(13) TYPE p DECIMALS 2,

price(13) TYPE p DECIMALS 2,

sum_101(13) TYPE p DECIMALS 2,

sum_102(13) TYPE p DECIMALS 2,

sum_sub_tot(13) TYPE p DECIMALS 2,

END OF it_final.

DATA:BEGIN OF st_final_display,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

menge TYPE mseg-menge,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

menges TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

rate(13) TYPE p DECIMALS 2,

value(13) TYPE p DECIMALS 2,

price(13) TYPE p DECIMALS 2,

sum_101(13) TYPE p DECIMALS 2,

sum_102(13) TYPE p DECIMALS 2,

sum_sub_tot(13) TYPE p DECIMALS 2,

index_id TYPE c,

line_color(4) TYPE c,

END OF st_final_display.

DATA: rate(12) TYPE p DECIMALS 2.

DATA: value(12) TYPE p DECIMALS 2.

DATA: price(12) TYPE p DECIMALS 2.

DATA: sum_101(13) TYPE p DECIMALS 2.

DATA: sum_102(13) TYPE p DECIMALS 2.

DATA: sum_sub_tot(13) TYPE p DECIMALS 2.

DATA it_std_mseg LIKE TABLE OF it_mseg WITH HEADER LINE.

DATA it_std_lfa1 LIKE TABLE OF it_lfa1 WITH HEADER LINE.

DATA it_std_ekpo LIKE TABLE OF it_ekpo WITH HEADER LINE.

DATA it_std_ekko LIKE TABLE OF it_ekko WITH HEADER LINE.

DATA it_std_ekbe LIKE TABLE OF it_ekbe WITH HEADER LINE.

DATA it_std_mkpf LIKE TABLE OF it_mkpf WITH HEADER LINE.

DATA it_std_final LIKE TABLE OF it_final WITH HEADER LINE.

DATA it_final_display LIKE TABLE OF st_final_display WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

SELECTION-SCREEN BEGIN OF BLOCK header WITH FRAME TITLE text-001.

PARAMETERS: P_WERKS LIKE MSEG-WERKS OBLIGATORY,

P_LGORT LIKE MSEG-LGORT OBLIGATORY.

  • P_EBELN LIKE MSEG-EBELN .

SELECT-OPTIONS: S_MATNR FOR MSEG-MATNR.

SELECT-OPTIONS: S_LIFNR FOR MSEG-LIFNR.

SELECT-OPTIONS: S_MATKL FOR EKPO-MATKL.

SELECT-OPTIONS: S_BEDAT FOR EKKO-BEDAT.

SELECTION-SCREEN END OF BLOCK header.

START-OF-SELECTION.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

START-OF-SELECTION.

PERFORM data_retrival.

PERFORM field.

*PERFORM SORT USING IT_SORT.

PERFORM events USING events.

  • PERFORM header USING top.

PERFORM layout.

PERFORM display.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * form data_retrival

  • * start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

FORM data_retrival.

SELECT mblnr mjahr zeile bwart matnr werks lgort lifnr dmbtr ebeln

ebelp lfpos lfbnr menge ps_psp_pnr

FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_std_mseg

WHERE werks = p_werks "AND EBELN = P_EBELN

AND lgort = p_lgort

AND lifnr IN s_lifnr

and ( bwart = '102' or bwart = '101' )

and menge gt 0

and ebeln ne space

and lgort ne space.

IF sy-subrc = 0.

SORT it_std_mseg BY lifnr ASCENDING.

SELECT lifnr name1 FROM lfa1 INTO

CORRESPONDING FIELDS OF TABLE it_std_lfa1

FOR ALL ENTRIES IN it_std_mseg

WHERE lifnr = it_std_mseg-lifnr

AND loevm = space.

IF sy-subrc = 0.

SORT it_std_lfa1 BY lifnr ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln ebelp matnr werks lgort ASCENDING.

SELECT ebeln ebelp txz01 matnr menge werks lgort matkl netwr effwr

FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_std_ekpo

FOR ALL ENTRIES IN it_std_mseg

WHERE ebeln = it_std_mseg-ebeln

AND ebelp = it_std_mseg-ebelp

AND matnr = it_std_mseg-matnr

AND werks = it_std_mseg-werks

AND lgort = it_std_mseg-lgort.

IF sy-subrc = 0.

SORT it_std_ekpo BY ebeln ebelp ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln lifnr ASCENDING.

SELECT ebeln bukrs bsart lifnr bedat

FROM ekko INTO CORRESPONDING FIELDS OF TABLE it_std_ekko

FOR ALL ENTRIES IN it_std_mseg

  • WHERE bsart = 'NB'

WHERE ebeln = it_std_mseg-ebeln

AND lifnr = it_std_mseg-lifnr .

IF sy-subrc = 0.

SORT it_std_ekko BY ebeln ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln ebelp lfbnr ASCENDING.

SELECT ebeln ebelp zekkn vgabe gjahr belnr buzei bwart budat xblnr

lfbnr FROM ekbe INTO CORRESPONDING FIELDS OF TABLE it_std_ekbe

FOR ALL ENTRIES IN it_std_mseg

WHERE ebeln = it_std_mseg-ebeln

AND ebelp = it_std_mseg-ebelp

AND lfbnr = it_std_mseg-lfbnr.

IF sy-subrc = 0.

SORT it_std_mseg BY ebeln ebelp ASCENDING.

ENDIF.

ENDIF.

IF NOT it_std_ekbe[] IS INITIAL.

SORT it_std_ekbe BY xblnr budat ASCENDING.

SELECT mblnr mjahr blart bldat budat xblnr

FROM mkpf INTO CORRESPONDING FIELDS OF TABLE it_std_mkpf

FOR ALL ENTRIES IN it_std_ekbe

WHERE xblnr = it_std_ekbe-xblnr

AND budat = it_std_ekbe-budat.

IF sy-subrc = 0.

SORT it_std_mkpf BY mblnr mjahr ASCENDING.

ENDIF.

ENDIF.

LOOP AT it_std_mseg.

it_std_final-mblnr = it_std_mseg-mblnr.

it_std_final-mjahr = it_std_mseg-mjahr.

it_std_final-zeile = it_std_mseg-zeile.

it_std_final-bwart = it_std_mseg-bwart.

it_std_final-matnr = it_std_mseg-matnr.

it_std_final-werks = it_std_mseg-werks.

it_std_final-lgort = it_std_mseg-lgort.

it_std_final-lifnr = it_std_mseg-lifnr.

it_std_final-dmbtr = it_std_mseg-dmbtr.

it_std_final-ebeln = it_std_mseg-ebeln.

it_std_final-ebelp = it_std_mseg-ebelp.

it_std_final-lfpos = it_std_mseg-lfpos.

it_std_final-lfbnr = it_std_mseg-lfbnr.

it_std_final-menge = it_std_mseg-menge.

it_std_final-ps_psp_pnr = it_std_mseg-ps_psp_pnr.

READ TABLE it_std_lfa1 WITH KEY lifnr = it_std_final-lifnr.

IF sy-subrc = 0.

it_std_final-name1 = it_std_lfa1-name1.

ENDIF.

READ TABLE it_std_ekpo WITH KEY ebeln = it_std_final-ebeln

ebelp = it_std_final-ebelp

matnr = it_std_final-matnr

werks = it_std_final-werks

lgort = it_std_final-lgort.

IF sy-subrc = 0.

it_std_final-txz01 = it_std_ekpo-txz01.

it_std_final-matkl = it_std_ekpo-matkl.

it_std_final-menges = it_std_ekpo-menge.

it_std_final-netwr = it_std_ekpo-netwr.

it_std_final-effwr = it_std_ekpo-effwr.

ENDIF.

READ TABLE it_std_ekko WITH KEY ebeln = it_std_final-ebeln

lifnr = it_std_final-lifnr.

IF sy-subrc = 0.

it_std_final-bukrs = it_std_ekko-bukrs.

it_std_final-bsart = it_std_ekko-bsart.

it_std_final-bedat = it_std_ekko-bedat.

ENDIF.

READ TABLE it_std_ekbe WITH KEY ebeln = it_std_final-ebeln

ebelp = it_std_final-ebelp

lfbnr = it_std_final-lfbnr

bwart = it_std_final-bwart.

IF sy-subrc = 0.

it_std_final-zekkn = it_std_ekbe-zekkn.

it_std_final-vgabe = it_std_ekbe-vgabe.

it_std_final-gjahr = it_std_ekbe-gjahr.

it_std_final-belnr = it_std_ekbe-belnr.

it_std_final-buzei = it_std_ekbe-buzei.

it_std_final-budat = it_std_ekbe-budat.

it_std_final-xblnr = it_std_ekbe-xblnr.

ENDIF.

READ TABLE it_std_mkpf WITH KEY xblnr = it_std_final-xblnr

budat = it_std_final-budat.

IF sy-subrc = 0.

it_std_final-blart = it_std_mkpf-blart.

it_std_final-bldat = it_std_mkpf-bldat.

ENDIF.

APPEND it_std_final.

CLEAR it_std_final.

ENDLOOP.

*include a field KEEP in the final table.

SORT it_std_final BY ebeln bwart ASCENDING.

DATA:wk_tot_val TYPE p DECIMALS 0.

LOOP AT it_std_final.

AT NEW ebeln.

CLEAR it_final_display.

CLEAR sum_101.

CLEAR sum_102.

CLEAR wk_tot_val.

ENDAT.

MOVE-CORRESPONDING it_std_final TO it_final_display.

APPEND it_final_display.

case it_std_final-bwart.

when '101'.

sum_101 = sum_101 + it_std_final-menge.

when '102'.

sum_102 = sum_102 + it_std_final-menge.

endcase.

AT END OF ebeln.

CLEAR it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-menge = wk_tot_val.

it_final_display-LIFNR = 'Sub Total'.

it_final_display-index_id = 'X'.

APPEND it_final_display.

ENDAT.

ENDLOOP.

it_final_display-line_color = 'C310'.

MODIFY it_final_display TRANSPORTING line_color WHERE index_id = 'X'.

LOOP AT IT_FINAL_DISPLAY.

IT_FINAL_DISPLAY-VALUE = IT_FINAL_DISPLAY-EFFWR - IT_FINAL_DISPLAY-NETWR.

IT_FINAL_DISPLAY-RATE = IT_FINAL_DISPLAY-VALUE / IT_FINAL_DISPLAY-MENGES.

*IT_FINAL_DISPLAY-PRICE = IT_FINAL_DISPLAY-RATE * IT_FINAL_DISPLAY-MENGE.*

*MODIFY IT_STD_FINAL.

ENDLOOP.

ENDFORM. " DATA_RETRIVAL

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*

  • * form data_retrival

  • * end

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*&----


**& Form FIELD

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM field .

lcat-fieldname = 'LIFNR'.

lcat-seltext_l = 'Vendor No'.

lcat-just = 'R'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'NAME1'.

lcat-seltext_l = 'Vendor Name'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'EBELN'.

lcat-seltext_l = 'PO No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BEDAT'.

lcat-seltext_l = 'Po Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MATNR'.

lcat-seltext_l = 'Mat No'.

lcat-just = 'R'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'TXZO1'.

lcat-seltext_l = 'Mat Description'.

lcat-just = 'R'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MBLNR'.

lcat-seltext_l = 'Document No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BLDAT'.

lcat-seltext_l = 'Doc Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BUDAT'.

lcat-seltext_l = 'Posting Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BWART'.

lcat-seltext_l = 'Mov type'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MENGE'.

lcat-seltext_l = 'Received Qty'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'XBLNR'.

lcat-seltext_l = 'Ref Dco No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'RATE'.

lcat-seltext_l = 'RATE'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'PRICE'.

lcat-seltext_l = 'VALUE'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

ENDFORM. " FIELD

*

*&----


**& Form DISPLAY

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM display .

CLEAR : it_std_mseg , it_std_ekbe , it_std_mkpf , it_std_ekpo , it_std_ekko , it_std_lfa1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • * I_INTERFACE_CHECK = ' '

  • * I_BYPASSING_BUFFER = ' '

  • * I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • * I_CALLBACK_PF_STATUS_SET = ' '

  • * I_CALLBACK_USER_COMMAND = ' '

  • * I_CALLBACK_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_END_OF_LIST = ' '

  • * I_STRUCTURE_NAME =

  • * I_BACKGROUND_ID = ' '

  • * I_GRID_TITLE =

  • * I_GRID_SETTINGS =

is_layout = layout

it_fieldcat = fieldcat[]

  • * IT_EXCLUDING =

  • * IT_SPECIAL_GROUPS =

*IT_SORT = IT_SORT

  • * IT_FILTER =

  • * IS_SEL_HIDE =

  • * I_DEFAULT = 'X'

  • * I_SAVE = ' '

  • * IS_VARIANT =

it_events = events

  • * IT_EVENT_EXIT =

  • * IS_PRINT =

  • * IS_REPREP_ID =

  • * I_SCREEN_START_COLUMN = 0

  • * I_SCREEN_START_LINE = 0

  • * I_SCREEN_END_COLUMN = 0

  • * I_SCREEN_END_LINE = 0

  • * I_HTML_HEIGHT_TOP = 0

  • * I_HTML_HEIGHT_END = 0

  • * IT_ALV_GRAPHICS =

  • * IT_HYPERLINK =

  • * IT_ADD_FIELDCAT =

  • * IT_EXCEPT_QINFO =

  • * IR_SALV_FULLSCREEN_ADAPTER =

  • * IMPORTING

  • * E_EXIT_CAUSED_BY_CALLER =

  • * ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_final_display[]

  • * 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. "DISPLAY

*&----


**& Form EVENTS

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM events USING p_events TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

ls_event-name = 'TOP_OF_PAGE'.

ls_event-form = 'TOP_OF_PAGE'.

APPEND ls_event TO p_events.

ENDFORM. " EVENTS

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = top.

ENDFORM. "TOP_OF_PAGE

*&----


**& Form HEADER

*&----


*

  • * text

*

*----


*

  • * -->P_TOP text

*

*----


*FORM header USING p_top TYPE slis_t_listheader.

*

  • DATA: ls_line TYPE slis_listheader.

*

  • DATA : asd(180),asd1(120).

*

  • CONCATENATE 'PURCHASE ORDER CHECKLIST FROM : ' s_bedat-low+6(2) '-'

  • s_bedat-low4(2) '-' s_bedat-low0(4) ' TO . ' s_bedat-high+6(2) '-'

  • s_bedat-high4(2) '-' s_bedat-high0(4) INTO asd.

  • CLEAR:ls_line.

  • ls_line-typ = 'H'.

  • ls_line-info = asd .

  • APPEND ls_line TO p_top.

  • CLEAR:ls_line.

*

**SELECT SINGLE NAME1 FROM PROJ INTO NAME1 WHERE WERKS = P_WERKS.

**

**CONCATENATE 'PROJECT : ' POST1 ' DATE :' SY-DATUM6(2) '-' SY-DATUM4(2) '-' SY-DATUM+0(4) INTO ASD1.

**

**

    • * ls_line-typ = 'H'.

    • * ls_line-info = ASD1.

    • * APPEND ls_line TO P_TOP.

*

*

  • SELECT SINGLE name1 FROM t001w INTO name1 WHERE werks = p_werks.

*

  • CONCATENATE 'PROJECT : ' name1 ' DATE :' sy-datum+6(2) '-'

  • sy-datum4(2) '-' sy-datum0(4) INTO asd1.

*

  • ls_line-typ = 'H'.

  • ls_line-info = asd1.

  • APPEND ls_line TO p_top.

*

*ENDFORM. " HEADER

*

*&----


**& Form SORT

*&----


*

  • *

  • o text

*

**----


*

  • *

  • o -->P_IT_SORT text

*----


FORM sort USING p_sort TYPE slis_t_sortinfo_alv.

DATA : lt_sort TYPE slis_sortinfo_alv.

lt_sort-fieldname = 'LIFNR'.

lt_sort-tabname = 'IT_STD_final'.

lt_sort-up = 'X'.

APPEND lt_sort TO p_sort.

CLEAR lt_sort.

lt_sort-fieldname = 'NAME1'.

lt_sort-tabname = 'IT_STD_final'.

lt_sort-up = 'X'.

APPEND lt_sort TO p_sort.

CLEAR lt_sort.

ENDFORM. " SORT

*&----


**& Form LAYOUT

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM layout .

layout-zebra = 'X'.

  • layout-info_fieldname = 'LINE'.

layout-info_fieldname = 'LINE_COLOR'.

layout-colwidth_optimize = 'X'.

APPEND layout." TO LAYOUT.

ENDFORM. " LAYOUT

Will Be waiting for ur reply......

kesavadas_thekkillath
Active Contributor
0 Kudos

Plz give me the code where the display comes correctly without this calculations...

Here EBELN in the input screen is a parameter type.

but u r question is to calculate based on different ebeln. how is it possible.

kesavadas_thekkillath
Active Contributor
0 Kudos

dear nalini,

i have written some thing similar to u r qn. plz debug this then u will be clear.....if not possible do revert for queries...do apply the same in ur code

&----


*& Report YMSEG *

*& *

&----


*& *

*& *

&----


REPORT ymseg .

TYPE-POOLS:slis.

DATA:BEGIN OF it_mseg OCCURS 0,

ebeln LIKE mseg-ebeln,

bwart LIKE mseg-bwart,

menge LIKE mseg-menge,

END OF it_mseg.

DATA :BEGIN OF it_final_display OCCURS 0,

ebeln LIKE mseg-ebeln,

bwart LIKE mseg-bwart,

menge LIKE mseg-menge,

index_id TYPE c,

line_color(4) TYPE c,

END OF it_final_display.

DATA:wk_tot_val TYPE p DECIMALS 0.

DATA: sum_101(13) TYPE p DECIMALS 2.

DATA: sum_102(13) TYPE p DECIMALS 2.

SELECT * FROM mseg CLIENT SPECIFIED

INTO CORRESPONDING FIELDS OF TABLE it_mseg

UP TO 500 ROWS

WHERE mandt = sy-mandt

AND ( bwart = '102' OR bwart = '101' )

AND ebeln <> space

AND bwart <> space

AND menge GT 0.

SORT it_mseg BY ebeln bwart ASCENDING.

LOOP AT it_mseg.

AT NEW ebeln.

CLEAR it_final_display.

CLEAR sum_101.

CLEAR sum_102.

CLEAR wk_tot_val.

ENDAT.

MOVE-CORRESPONDING it_mseg TO it_final_display.

APPEND it_final_display.

CASE it_mseg-bwart.

WHEN '102'.

sum_102 = sum_102 + it_mseg-menge.

WHEN '101'.

sum_101 = sum_101 + it_mseg-menge.

ENDCASE.

AT END OF ebeln.

CLEAR it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-menge = wk_tot_val.

it_final_display-ebeln = 'Subtotal'.

it_final_display-index_id = 'X'.

APPEND it_final_display.

ENDAT.

ENDLOOP.

it_final_display-line_color = 'C300'.

MODIFY it_final_display TRANSPORTING line_color WHERE index_id = 'X'.

DATA: alvfld TYPE slis_fieldcat_alv,

fieldcat TYPE slis_t_fieldcat_alv,

wk_layout TYPE slis_layout_alv.

wk_layout-info_fieldname = 'LINE_COLOR'.

wk_layout-colwidth_optimize = 'X'.

alvfld-fieldname = 'EBELN'.

alvfld-seltext_m = 'Doc No'.

APPEND alvfld TO fieldcat.

alvfld-fieldname = 'BWART'.

alvfld-seltext_m = 'Mvmnt type'.

APPEND alvfld TO fieldcat.

alvfld-fieldname = 'MENGE'.

alvfld-seltext_m = 'Qty'.

APPEND alvfld TO fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = fieldcat[]

is_layout = wk_layout

TABLES

t_outtab = it_final_display[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

kesavadas_thekkillath
Active Contributor
0 Kudos

Any Queries fell free to ask...

my id kesav2005@rediffmail.com

kesavadas_thekkillath
Active Contributor
0 Kudos

Dear frnd,

I have corrected your prg..i have modified some select queries which suits my data...check and apply yours

REPORT a.

TABLES : mseg , ekbe , mkpf , ekpo ,ekko, lfa1, t001w.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Tables Declaration Section

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TYPE-POOLS : slis.

DATA : fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

layout TYPE slis_layout_alv OCCURS 1 WITH HEADER LINE ,

lcat TYPE slis_fieldcat_alv.

DATA: top TYPE slis_t_listheader,

events TYPE slis_t_event.

DATA : name1 LIKE proj-post1,

werks LIKE t001w-werks.

DATA : t_key TYPE slis_keyinfo_alv.

DATA: it_sort TYPE slis_t_sortinfo_alv ."WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Internal Table Definitions

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DATA: BEGIN OF it_mseg,

ebeln TYPE mseg-ebeln, "<----place this as first field

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

ebelp TYPE mseg-ebelp,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

menge TYPE mseg-menge,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

END OF it_mseg.

DATA: BEGIN OF it_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF it_lfa1.

DATA: BEGIN OF it_ekpo,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

txz01 TYPE ekpo-txz01,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

END OF it_ekpo.

DATA: BEGIN OF it_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

bedat TYPE ekko-bedat,

END OF it_ekko.

DATA: BEGIN OF it_ekbe,

ebeln TYPE ekbe-ebeln,

ebelp TYPE ekbe-ebelp,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

bwart TYPE ekbe-bwart,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

lfbnr TYPE ekbe-lfbnr,

END OF it_ekbe.

DATA: BEGIN OF it_mkpf,

mblnr TYPE mkpf-mblnr,

mjahr TYPE mkpf-mjahr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

budat TYPE mkpf-budat,

xblnr TYPE mkpf-xblnr,

END OF it_mkpf.

DATA: BEGIN OF it_final,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

menge TYPE mseg-menge,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

menges TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

rate(13) TYPE p DECIMALS 2,

value(13) TYPE p DECIMALS 2,

price(13) TYPE p DECIMALS 2,

sum_101(13) TYPE p DECIMALS 2,

sum_102(13) TYPE p DECIMALS 2,

sum_sub_tot(13) TYPE p DECIMALS 2,

END OF it_final.

DATA:BEGIN OF st_final_display,

ebeln TYPE mseg-ebeln,

ebelp TYPE mseg-ebelp,

menge TYPE mseg-menge,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

zeile TYPE mseg-zeile,

bwart TYPE mseg-bwart,

matnr TYPE mseg-matnr,

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

lifnr TYPE mseg-lifnr,

dmbtr TYPE mseg-dmbtr,

lfpos TYPE mseg-lfpos,

lfbnr TYPE mseg-lfbnr,

ps_psp_pnr TYPE mseg-ps_psp_pnr,

name1 TYPE lfa1-name1,

txz01 TYPE ekpo-txz01,

matkl TYPE ekpo-matkl,

menges TYPE ekpo-menge,

netwr TYPE ekpo-netwr,

effwr TYPE ekpo-effwr,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

bedat TYPE ekko-bedat,

zekkn TYPE ekbe-zekkn,

vgabe TYPE ekbe-vgabe,

gjahr TYPE ekbe-gjahr,

belnr TYPE ekbe-belnr,

buzei TYPE ekbe-buzei,

budat TYPE ekbe-budat,

xblnr TYPE ekbe-xblnr,

blart TYPE mkpf-blart,

bldat TYPE mkpf-bldat,

rate(13) TYPE p DECIMALS 2,

value(13) TYPE p DECIMALS 2,

price(13) TYPE p DECIMALS 2,

sum_101(13) TYPE p DECIMALS 2,

sum_102(13) TYPE p DECIMALS 2,

sum_sub_tot(13) TYPE p DECIMALS 2,

index_id TYPE c,

line_color(4) TYPE c,

END OF st_final_display.

DATA: rate(12) TYPE p DECIMALS 2.

DATA: value(12) TYPE p DECIMALS 2.

DATA: price(12) TYPE p DECIMALS 2.

DATA: sum_101(13) TYPE p DECIMALS 2.

DATA: sum_102(13) TYPE p DECIMALS 2.

DATA: sum_sub_tot(13) TYPE p DECIMALS 2.

DATA it_std_mseg LIKE TABLE OF it_mseg WITH HEADER LINE.

DATA it_std_lfa1 LIKE TABLE OF it_lfa1 WITH HEADER LINE.

DATA it_std_ekpo LIKE TABLE OF it_ekpo WITH HEADER LINE.

DATA it_std_ekko LIKE TABLE OF it_ekko WITH HEADER LINE.

DATA it_std_ekbe LIKE TABLE OF it_ekbe WITH HEADER LINE.

DATA it_std_mkpf LIKE TABLE OF it_mkpf WITH HEADER LINE.

DATA it_std_final LIKE TABLE OF it_final WITH HEADER LINE.

DATA it_final_display LIKE TABLE OF st_final_display WITH HEADER LINE.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * Start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

SELECTION-SCREEN BEGIN OF BLOCK header WITH FRAME TITLE text-001.

PARAMETERS: p_werks LIKE mseg-werks OBLIGATORY.

  • p_lgort LIKE mseg-lgort ."OBLIGATORY,

SELECT-OPTIONS: p_lgort for mseg-lgort.

SELECT-OPTIONS: s_lifnr FOR mseg-lifnr.

SELECTION-SCREEN END OF BLOCK header.

START-OF-SELECTION.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * Selection-Screen

  • * End

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

START-OF-SELECTION.

PERFORM data_retrival.

PERFORM field.

*PERFORM SORT USING IT_SORT.

PERFORM events USING events.

  • PERFORM header USING top.

PERFORM layout.

PERFORM display.

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  • * form data_retrival

  • * start

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

FORM data_retrival.

SELECT mblnr mjahr zeile bwart matnr werks lgort lifnr dmbtr ebeln

ebelp lfpos lfbnr menge ps_psp_pnr

FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_std_mseg

WHERE werks = p_werks

AND lgort in p_lgort

AND lifnr IN s_lifnr

and ( bwart = '102' or bwart = '101' )

and menge gt 0

and ebeln ne space

and lgort ne space.

IF sy-subrc = 0.

SORT it_std_mseg BY lifnr ASCENDING.

SELECT lifnr name1 FROM lfa1 INTO

CORRESPONDING FIELDS OF TABLE it_std_lfa1

FOR ALL ENTRIES IN it_std_mseg

WHERE lifnr = it_std_mseg-lifnr

AND loevm = space.

IF sy-subrc = 0.

SORT it_std_lfa1 BY lifnr ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln ebelp matnr werks lgort ASCENDING.

SELECT ebeln ebelp txz01 matnr menge werks lgort matkl netwr effwr

FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_std_ekpo

FOR ALL ENTRIES IN it_std_mseg

WHERE ebeln = it_std_mseg-ebeln

AND ebelp = it_std_mseg-ebelp

AND matnr = it_std_mseg-matnr

AND werks = it_std_mseg-werks

AND lgort = it_std_mseg-lgort.

IF sy-subrc = 0.

SORT it_std_ekpo BY ebeln ebelp ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln lifnr ASCENDING.

SELECT ebeln bukrs bsart lifnr bedat

FROM ekko INTO CORRESPONDING FIELDS OF TABLE it_std_ekko

FOR ALL ENTRIES IN it_std_mseg

  • WHERE bsart = 'NB'

WHERE ebeln = it_std_mseg-ebeln

AND lifnr = it_std_mseg-lifnr .

IF sy-subrc = 0.

SORT it_std_ekko BY ebeln ASCENDING.

ENDIF.

SORT it_std_mseg BY ebeln ebelp lfbnr ASCENDING.

SELECT ebeln ebelp zekkn vgabe gjahr belnr buzei bwart budat xblnr

lfbnr FROM ekbe INTO CORRESPONDING FIELDS OF TABLE it_std_ekbe

FOR ALL ENTRIES IN it_std_mseg

WHERE ebeln = it_std_mseg-ebeln

AND ebelp = it_std_mseg-ebelp

AND lfbnr = it_std_mseg-lfbnr.

IF sy-subrc = 0.

SORT it_std_mseg BY ebeln ebelp ASCENDING.

ENDIF.

ENDIF.

IF NOT it_std_ekbe[] IS INITIAL.

SORT it_std_ekbe BY xblnr budat ASCENDING.

SELECT mblnr mjahr blart bldat budat xblnr

FROM mkpf INTO CORRESPONDING FIELDS OF TABLE it_std_mkpf

FOR ALL ENTRIES IN it_std_ekbe

WHERE xblnr = it_std_ekbe-xblnr

AND budat = it_std_ekbe-budat.

IF sy-subrc = 0.

SORT it_std_mkpf BY mblnr mjahr ASCENDING.

ENDIF.

ENDIF.

LOOP AT it_std_mseg.

it_std_final-mblnr = it_std_mseg-mblnr.

it_std_final-mjahr = it_std_mseg-mjahr.

it_std_final-zeile = it_std_mseg-zeile.

it_std_final-bwart = it_std_mseg-bwart.

it_std_final-matnr = it_std_mseg-matnr.

it_std_final-werks = it_std_mseg-werks.

it_std_final-lgort = it_std_mseg-lgort.

it_std_final-lifnr = it_std_mseg-lifnr.

it_std_final-dmbtr = it_std_mseg-dmbtr.

it_std_final-ebeln = it_std_mseg-ebeln.

it_std_final-ebelp = it_std_mseg-ebelp.

it_std_final-lfpos = it_std_mseg-lfpos.

it_std_final-lfbnr = it_std_mseg-lfbnr.

it_std_final-menge = it_std_mseg-menge.

it_std_final-ps_psp_pnr = it_std_mseg-ps_psp_pnr.

READ TABLE it_std_lfa1 WITH KEY lifnr = it_std_final-lifnr.

IF sy-subrc = 0.

it_std_final-name1 = it_std_lfa1-name1.

ENDIF.

READ TABLE it_std_ekpo WITH KEY ebeln = it_std_final-ebeln

ebelp = it_std_final-ebelp

matnr = it_std_final-matnr

werks = it_std_final-werks

lgort = it_std_final-lgort.

IF sy-subrc = 0.

it_std_final-txz01 = it_std_ekpo-txz01.

it_std_final-matkl = it_std_ekpo-matkl.

it_std_final-menges = it_std_ekpo-menge.

it_std_final-netwr = it_std_ekpo-netwr.

it_std_final-effwr = it_std_ekpo-effwr.

ENDIF.

READ TABLE it_std_ekko WITH KEY ebeln = it_std_final-ebeln

lifnr = it_std_final-lifnr.

IF sy-subrc = 0.

it_std_final-bukrs = it_std_ekko-bukrs.

it_std_final-bsart = it_std_ekko-bsart.

it_std_final-bedat = it_std_ekko-bedat.

ENDIF.

READ TABLE it_std_ekbe WITH KEY ebeln = it_std_final-ebeln

ebelp = it_std_final-ebelp

lfbnr = it_std_final-lfbnr

bwart = it_std_final-bwart.

IF sy-subrc = 0.

it_std_final-zekkn = it_std_ekbe-zekkn.

it_std_final-vgabe = it_std_ekbe-vgabe.

it_std_final-gjahr = it_std_ekbe-gjahr.

it_std_final-belnr = it_std_ekbe-belnr.

it_std_final-buzei = it_std_ekbe-buzei.

it_std_final-budat = it_std_ekbe-budat.

it_std_final-xblnr = it_std_ekbe-xblnr.

ENDIF.

READ TABLE it_std_mkpf WITH KEY xblnr = it_std_final-xblnr

budat = it_std_final-budat.

IF sy-subrc = 0.

it_std_final-blart = it_std_mkpf-blart.

it_std_final-bldat = it_std_mkpf-bldat.

ENDIF.

APPEND it_std_final.

CLEAR it_std_final.

ENDLOOP.

*include a field KEEP in the final table.

SORT it_std_final BY ebeln bwart ASCENDING.

DATA:wk_tot_val TYPE p DECIMALS 0.

LOOP AT it_std_final.

AT NEW ebeln.

CLEAR it_final_display.

CLEAR sum_101.

CLEAR sum_102.

CLEAR wk_tot_val.

ENDAT.

MOVE-CORRESPONDING it_std_final TO it_final_display.

APPEND it_final_display.

case it_std_mseg-bwart.

when '101'.

sum_101 = sum_101 + it_std_mseg-menge.

when '102'.

sum_102 = sum_102 + it_std_mseg-menge.

endcase.

AT END OF ebeln.

CLEAR it_final_display.

wk_tot_val = sum_101 - sum_102.

it_final_display-menge = wk_tot_val.

it_final_display-LIFNR = 'Sub Total'.

it_final_display-index_id = 'X'.

append it_final_display.

ENDAT.

ENDLOOP.

it_final_display-line_color = 'C310'.

MODIFY it_final_display TRANSPORTING line_color WHERE index_id = 'X'.

ENDFORM. " DATA_RETRIVAL

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*

  • * form data_retrival

  • * end

*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*&----


**& Form FIELD

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM field .

lcat-fieldname = 'LIFNR'.

lcat-seltext_l = 'Vendor No'.

lcat-just = 'R'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'NAME1'.

lcat-seltext_l = 'Name'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'EBELN'.

lcat-seltext_l = 'PO No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BEDAT'.

lcat-seltext_l = 'Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MATNR'.

lcat-seltext_l = 'Material No'.

lcat-just = 'R'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'PS_PSP_PNR'.

lcat-seltext_l = 'WBS'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'TXZ01'.

lcat-seltext_l = 'Short text'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MENGE'.

lcat-seltext_l = 'RECEIVED QTY'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BWART'.

lcat-seltext_l = 'Movement type'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'MBLNR'.

lcat-seltext_l = 'Document No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BLDAT'.

lcat-seltext_l = 'Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'XBLNR'.

lcat-seltext_l = 'Ref Dco No'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

lcat-fieldname = 'BUDAT'.

lcat-seltext_l = 'Date'.

lcat-just = 'L'.

APPEND lcat TO fieldcat.

CLEAR lcat.

ENDFORM. " FIELD

*

*&----


**& Form DISPLAY

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM display .

CLEAR : it_std_mseg , it_std_ekbe , it_std_mkpf , it_std_ekpo , it_std_ekko , it_std_lfa1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • * I_INTERFACE_CHECK = ' '

  • * I_BYPASSING_BUFFER = ' '

  • * I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • * I_CALLBACK_PF_STATUS_SET = ' '

  • * I_CALLBACK_USER_COMMAND = ' '

  • * I_CALLBACK_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • * I_CALLBACK_HTML_END_OF_LIST = ' '

  • * I_STRUCTURE_NAME =

  • * I_BACKGROUND_ID = ' '

  • * I_GRID_TITLE =

  • * I_GRID_SETTINGS =

is_layout = layout

it_fieldcat = fieldcat[]

  • * IT_EXCLUDING =

  • * IT_SPECIAL_GROUPS =

*IT_SORT = IT_SORT

  • * IT_FILTER =

  • * IS_SEL_HIDE =

  • * I_DEFAULT = 'X'

  • * I_SAVE = ' '

  • * IS_VARIANT =

it_events = events

  • * IT_EVENT_EXIT =

  • * IS_PRINT =

  • * IS_REPREP_ID =

  • * I_SCREEN_START_COLUMN = 0

  • * I_SCREEN_START_LINE = 0

  • * I_SCREEN_END_COLUMN = 0

  • * I_SCREEN_END_LINE = 0

  • * I_HTML_HEIGHT_TOP = 0

  • * I_HTML_HEIGHT_END = 0

  • * IT_ALV_GRAPHICS =

  • * IT_HYPERLINK =

  • * IT_ADD_FIELDCAT =

  • * IT_EXCEPT_QINFO =

  • * IR_SALV_FULLSCREEN_ADAPTER =

  • * IMPORTING

  • * E_EXIT_CAUSED_BY_CALLER =

  • * ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_final_display[]

  • * 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. "DISPLAY

*&----


**& Form EVENTS

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM events USING p_events TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

ls_event-name = 'TOP_OF_PAGE'.

ls_event-form = 'TOP_OF_PAGE'.

APPEND ls_event TO p_events.

ENDFORM. " EVENTS

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = top.

ENDFORM. "TOP_OF_PAGE

*&----


**& Form HEADER

*&----


*

  • * text

*

*----


*

  • * -->P_TOP text

*

*----


*FORM header USING p_top TYPE slis_t_listheader.

*

  • DATA: ls_line TYPE slis_listheader.

*

  • DATA : asd(180),asd1(120).

*

  • CONCATENATE 'PURCHASE ORDER CHECKLIST FROM : ' s_bedat-low+6(2) '-'

  • s_bedat-low4(2) '-' s_bedat-low0(4) ' TO . ' s_bedat-high+6(2) '-'

  • s_bedat-high4(2) '-' s_bedat-high0(4) INTO asd.

  • CLEAR:ls_line.

  • ls_line-typ = 'H'.

  • ls_line-info = asd .

  • APPEND ls_line TO p_top.

  • CLEAR:ls_line.

*

**SELECT SINGLE NAME1 FROM PROJ INTO NAME1 WHERE WERKS = P_WERKS.

**

**CONCATENATE 'PROJECT : ' POST1 ' DATE :' SY-DATUM6(2) '-' SY-DATUM4(2) '-' SY-DATUM+0(4) INTO ASD1.

**

**

    • * ls_line-typ = 'H'.

    • * ls_line-info = ASD1.

    • * APPEND ls_line TO P_TOP.

*

*

  • SELECT SINGLE name1 FROM t001w INTO name1 WHERE werks = p_werks.

*

  • CONCATENATE 'PROJECT : ' name1 ' DATE :' sy-datum+6(2) '-'

  • sy-datum4(2) '-' sy-datum0(4) INTO asd1.

*

  • ls_line-typ = 'H'.

  • ls_line-info = asd1.

  • APPEND ls_line TO p_top.

*

*ENDFORM. " HEADER

*

*&----


**& Form SORT

*&----


*

  • *

  • o text

*

**----


*

  • *

  • o -->P_IT_SORT text

*----


FORM sort USING p_sort TYPE slis_t_sortinfo_alv.

DATA : lt_sort TYPE slis_sortinfo_alv.

lt_sort-fieldname = 'LIFNR'.

lt_sort-tabname = 'IT_STD_final'.

lt_sort-up = 'X'.

APPEND lt_sort TO p_sort.

CLEAR lt_sort.

lt_sort-fieldname = 'NAME1'.

lt_sort-tabname = 'IT_STD_final'.

lt_sort-up = 'X'.

APPEND lt_sort TO p_sort.

CLEAR lt_sort.

ENDFORM. " SORT

*&----


**& Form LAYOUT

*&----


*

  • * text

*

*----


*

  • * --> p1 text

  • * <-- p2 text

*

*----


FORM layout .

layout-zebra = 'X'.

  • layout-info_fieldname = 'LINE'.

layout-info_fieldname = 'LINE_COLOR'.

layout-colwidth_optimize = 'X'.

APPEND layout." TO LAYOUT.

ENDFORM. " LAYOUT

0 Kudos

Keshu,

Ur very much Perfect with the Report........I am Really Happy for being with me and Helping me in this Report.......I will now Try to Complete my Whole Report...........according to the Client Requirement......But Almost Every thing U have Done.....Credit Goes to U.....

I will be Giving u Full Points.........and if any More Points are Allocated .....

i would have given U the Highest Points.....

Every one is Lucky to Get u in this Forum....

U were Very helpful....

I want to be Surely in Touch with u and Learn More things frm U....

Please Help me.....

Thanks Dear,

Nalini

0 Kudos

Thnks for the comment,

Any queries feel free to ask.....i have mentioned my ID above....