Skip to Content
0
Aug 01, 2007 at 06:03 AM

please verify my report at selection event is not executing ?

40 Views

hi all.

iam not able find where my mistake please check intialisation event also.

REPORT zsdr_retail1 NO STANDARD PAGE HEADING LINE-SIZE 300.

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

  • Table Definitions

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

TABLES : knvh, "Customer Hierarchies

  • kna1, "General Data in Customer Master

konv, "Conditions (Item)

vbak, "Sales Document: Header Data

vbap, "Sales Document: Item Data

vbpa. "Sales Document: Partner

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

  • Internal Tables declaration

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

DATA : BEGIN OF it_knvh OCCURS 0,

hkunnr LIKE knvh-hkunnr, "Customer number of thehigher-level

  • customer hierarchy

hspart LIKE knvh-hspart, "Higher-level division

hvtweg LIKE knvh-hvtweg, "Higher-level distribution channel

kunnr LIKE knvh-kunnr, "Customer

spart LIKE knvh-spart, "Division

vtweg LIKE knvh-vtweg, "Distribution Channel

END OF it_knvh.

DATA : BEGIN OF it_vbak OCCURS 0,

posnr LIKE vbap-posnr, "Sales Document Item

erdat LIKE vbak-erdat, "Date on Which Record Was Created

bstzd LIKE vbak-bstzd, "Purchase order numbersupplement

vbeln LIKE vbak-vbeln, "Sales Document

matnr LIKE vbap-matnr, "Material Number

mwsbp LIKE vbap-mwsbp, "Tax amount in document currency

kwmeng LIKE vbap-kwmeng,"Cumulative Order Quantityin SalesUnits

knumh LIKE vbap-knumh, "Number of the documentcondition

******"Work Breakdown StructureElement (WBS Element)/project ID

ps_psp_pnr LIKE vbap-ps_psp_pnr,

  • "Net Value of the Sales Order in Document Currency

netvalue LIKE vbap-netwr,

kwert LIKE konv-kwert,

END OF it_vbak.

DATA : BEGIN OF it_konv OCCURS 0,

knumv LIKE konv-knumh, "Number of the documentcondition

kschl LIKE konv-kschl, "Condition type

kwert LIKE konv-kwert, "Condition value

sellingprice LIKE konv-kwert,

discounts LIKE konv-kwert,

surcharges LIKE konv-kwert,

grossamount LIKE konv-kwert,

END OF it_konv.

DATA : BEGIN OF it_display OCCURS 0,

kunnr LIKE knvh-kunnr,

matnr LIKE vbap-matnr,

sellingprice LIKE konv-kwert,

ps_psp_pnr LIKE vbap-ps_psp_pnr,

kwmeng LIKE vbap-kwmeng,

bstzd LIKE vbak-bstzd,

vtweg LIKE knvh-vtweg,

discounts LIKE konv-kwert,

mwsbp LIKE vbap-mwsbp,

surcharges LIKE konv-kwert,

netvalue LIKE vbap-netwr,

grossamount LIKE konv-kwert,

END OF it_display.

DATA i_knvh LIKE TABLE OF knvh WITH HEADER LINE.

DATA : i_dynpread LIKE dynpread OCCURS 0 WITH HEADER LINE.

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

  • Selection Screen Definitions

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

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE b001.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE a001.

PARAMETERS : p_hkunnr TYPE knvh-hkunnr OBLIGATORY,

p_kunnr LIKE knvh-kunnr. " OBLIGATORY.

SELECT-OPTIONS : s_erdat FOR vbak-erdat,

s_p_p_pr FOR vbap-ps_psp_pnr.

PARAMETERS : p_hspart TYPE knvh-hspart OBLIGATORY,

p_hvtweg TYPE knvh-hvtweg OBLIGATORY.

SELECT-OPTIONS : s_bstzd FOR vbak-bstzd.

SELECTION-SCREEN END OF BLOCK a1.

SELECTION-SCREEN END OF BLOCK b1.

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

  • INITIALIZATION

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

INITIALIZATION.

a001 = 'SELECTION CRITERIA'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_kunnr .

REFRESH i_dynpread.

i_dynpread-fieldname = 'p_hkunnr'.

APPEND i_dynpread.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-repid

dynumb = '1000'

TABLES

dynpfields = i_dynpread

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

stepl_not_found = 10

OTHERS = 11.

.

READ TABLE i_dynpread INDEX 1.

p_hkunnr = i_dynpread-fieldvalue.

SELECT * FROM knvh

INTO TABLE i_knvh

WHERE kunnr = p_hkunnr.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'kunnr'

dynpprog = sy-repid

dynpnr = '1000'

dynprofield = 'p_kunnr'

value_org = 'S'

TABLES

value_tab = i_knvh.

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

  • START-OF-SELECTION

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

START-OF-SELECTION.

  • PERFORM get_data.

  • PERFORM header_data.

  • PERFORM process_data.

  • PERFORM display_data.

*end-of-selection.

END-OF-SELECTION.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

  • SELECT a~vbeln

  • a~erdat

  • a~bstzd

  • a~knumv

  • b~posnr

  • b~matnr

  • b~mwsbp

  • b~kwmeng

  • b~netwr

  • b~ps_psp_pnr

  • c~hkunnr

  • c~kunnr

  • c~hspart

  • c~hspart

  • c~hvtweg

  • c~kunnr

  • c~spart

  • c~vtweg

  • FROM vbak AS a INNER JOIN vbap AS b ON avbeln = bvbeln

  • INNER JOIN knvh AS c ON akunnr = ckunnr

  • INTO CORRESPONDING FIELDS OF TABLE it_vbak

  • WHERE c~hkunnr = p_kunnr

  • AND c~kunnr = p_kunnr

  • AND a~erdat IN s_erdat

  • and b~p_p_pr in s_ps_psp_pnr

  • AND a~bstzd IN s_bstzd

  • AND c~spart IN s_spart

  • AND c~parvw IN s_parvw.

IF it_vbak[] IS NOT INITIAL.

SELECT knumh kschl kbetr kwert FROM konv INTO CORRESPONDING FIELDS

OF TABLE it_konv

FOR ALL ENTRIES IN it_vbak

WHERE knumh = it_vbak-knumh.

ENDIF.

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

  • To get the values for selling price, surcharges and discounts

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

LOOP AT it_konv.

CASE it_konv-kschl.

WHEN 'PR00'.

it_konv-sellingprice = it_konv-kwert.

WHEN 'ZD01' OR 'ZD02' OR 'ZD03'.

it_konv-discounts = it_konv-kwert.

WHEN 'ZEXP' OR 'ZEXW' OR 'ZCAF' OR 'ZCAP' OR 'ZCAQ'

OR 'ZS01' OR 'ZS02' OR 'ZS03'.

it_konv-surcharges = it_konv-kwert.

ENDCASE.

MODIFY it_konv INDEX sy-tabix TRANSPORTING sellingprice discounts

surcharges.

ENDLOOP.

.

ENDFORM. " GET_DATA

&----


*& Form process_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*FORM process_data .

  • SORT it_vbak BY vbeln.

*

*

  • LOOP AT it_vbak.

  • LOOP AT it_konv WHERE knumv = it_vbak-knumh.

  • it_display-kunnr = it_vbak-kunnr.

  • it_display-matnr = it_vbak-matnr.

  • it_display-parvw = it_vbak-parvw.

  • it_display-kwmeng = it_vbak-kwmeng.

  • it_display-bstzd = it_vbak-bstzd.

  • it_display-vtweg = it_vbak-vtweg.

  • it_display-mwsbp = it_vbak-mwsbp.

  • it_display-netvalue = it_vbak-netvalue.

  • it_display-ps_psp_pnr = it_vbak-ps_psp_pnr.

  • it_display-sellingprice = it_konv-sellingprice.

  • it_display-discounts = it_konv-discounts.

  • it_display-surcharges = it_konv-surcharges.

  • it_display-grossamount = it_konv-grossamount.

  • it_display-grossamount = it_display-sellingprice -

  • it_display-discounts +

  • it_display-mwsbp +

  • it_display-surcharges.

  • it_display-netvalue = it_display-sellingprice -

  • it_display-discounts.

*

  • APPEND it_display.

  • ENDLOOP.

  • ENDLOOP.

*ENDFORM. " process_data

*

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_data .

LOOP AT it_display .

DELETE it_display WHERE sellingprice IS INITIAL.

ENDLOOP.

LOOP AT it_display .

WRITE : /1 sy-vline, it_display-kunnr CENTERED, 12 sy-vline,

it_display-matnr CENTERED, 32 sy-vline,

it_display-sellingprice CENTERED, 48 sy-vline,

it_display-ps_psp_pnr CENTERED, 66 sy-vline,

it_display-kwmeng CENTERED, 83 sy-vline, it_display-bstzd

CENTERED, 94 sy-vline, it_display-vtweg CENTERED,

109 sy-vline, it_display-discounts CENTERED, 121 sy-vline

, it_display-mwsbp CENTERED, 136 sy-vline,

it_display-surcharges CENTERED, 151 sy-vline,

it_display-netvalue CENTERED, 169 sy-vline, it_display-grossamount

CENTERED,

187 sy-vline.

ENDLOOP.

ULINE (187).

ENDFORM. " display_data

&----


*& Form header_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header_data .

DATA : days LIKE dtresr-weekday.

CALL FUNCTION 'DATE_TO_DAY'

EXPORTING

date = sy-datum

IMPORTING

weekday = days.

WRITE : 15 'NOEL GIFTS INTERNATIONAL LIMITED', 60 sy-uname, days,

sy-datum, sy-uzeit, 'Pg no':, sy-pagno.

WRITE : /60 sy-repid.

WRITE : /40 s_erdat-low, 22 s_erdat-high.

  • WRITE : /40 s_parvw-low, 22 s_parvw-high.

  • WRITE : /40 s_parvw.

  • WRITE : /40 s_p_p_pr.

SKIP 2.

ULINE (187).

WRITE : /1 sy-vline,'CUSTOMER', 12 sy-vline, 'MATERIAL', 32 sy-vline,

'SELLING PRICE', 48 sy-vline, 'PROJECT ID' ,

66 sy-vline, 'QUANTITY', 83 sy-vline, ' ORD.SOUR.', 94

sy-vline, 'DIST.CHANNEL', 109 sy-vline, 'DISCOUNTS',

121 sy-vline, 'GST', 136 sy-vline, 'SURCHARGES', 151 sy-vline

, ' NET VALUE', 169 sy-vline, ' GROSS AMOUNT ', 187 sy-vline.

ULINE (187).

endform.