Skip to Content
0
Former Member
Sep 11, 2007 at 11:02 AM

Re: URGENT: REGARDING ALV REPORT

19 Views

Hi,

I had made this report and when i want to display d calculations which i had done and stored in variables its total is not displaying and also the print preview. can anbody provide d solution of dis problem. its really urgent.

He or she will be definately rewarded.....

REPORT ZMFTEST5 no standard page heading LINE-SIZE 310.

TABLES : VBAK,ABAP,VBEP,VBKD,MARA,KNA1,MAKT.

*Varriable declaration.

TYPE-POOLS SLIS.

  • INTERNAL TABLE FOR SALES ORDER *****************

DATA : BEGIN OF ITSO OCCURS 0,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

BSTNK LIKE VBAK-BSTNK,

KUNNR LIKE VBAK-KUNNR,

MATNR LIKE VBAP-MATNR,

POSNR LIKE VBAP-POSNR,

WMENG LIKE VBEP-WMENG,

NTGEW LIKE MARA-NTGEW,

BRGEW LIKE MARA-BRGEW,

GEWEI LIKE MARA-GEWEI,

SPART LIKE VBAK-SPART,

BMENG LIKE VBEP-BMENG,

EDATU LIKE VBEP-EDATU,

BSTKD LIKE VBKD-BSTKD,

WERKS LIKE VBAP-WERKS,

MEINS LIKE MARA-MEINS,

KWMENG LIKE VBAP-KWMENG,

KLMENG LIKE VBAP-KLMENG,

BALQTY LIKE VBAP-KLMENG,

SOGWT LIKE MARA-BRGEW,

SONWT LIKE MARA-BRGEW,

SINWT LIKE MARA-BRGEW,

BALGWT LIKE MARA-BRGEW,

BALNWT LIKE MARA-BRGEW,

DISPNWT LIKE MARA-BRGEW,

PARTYNAME LIKE KNA1-NAME1,

ITEMDESC LIKE MAKT-MAKTX,

STATUS TYPE C,

END OF ITSO.

data: t_heading type slis_t_listheader.

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

***********PARAMETERS***************

PARAMETERS : PLANT LIKE VBAP-WERKS OBLIGATORY.

*********SELECTION SCREEN OPTIONS*********

SELECT-OPTIONS : SO_ORD FOR VBAK-VBELN,

SO_PARTY FOR VBAK-KUNNR,

IT_M FOR MARA-MATNR,

DIV FOR VBAK-SPART,

SO_DATE FOR VBAK-ERDAT,

S_DATE FOR VBEP-EDATU.

*********DEFINING VARIABLES*********

SELECTION-SCREEN END OF BLOCK par1.

DATA : SCH_DATE LIKE VBEP-EDATU,

V_ITEM LIKE MAKT-MAKTX,

V_ADDR LIKE KNA1-NAME1,

B_QTY TYPE P LENGTH 7 DECIMALS 3,

B_GR_W TYPE P LENGTH 5 DECIMALS 3,

B_NT_W TYPE P LENGTH 5 DECIMALS 3,

ITEM_NTW TYPE P LENGTH 5 DECIMALS 3,

ITEM_GRW TYPE P LENGTH 5 DECIMALS 3,

ITEM_DISP TYPE P LENGTH 5 DECIMALS 3,

CNT(5) TYPE N.

TOP-OF-PAGE.

PERFORM PG_HEADER.

START-OF-SELECTION.

SELECTION-SCREEN BEGIN OF BLOCK OPSC

WITH FRAME TITLE TEXT-002.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS PEND RADIOBUTTON GROUP OP DEFAULT 'X'.

SELECTION-SCREEN COMMENT 4(30) TEXT-011 FOR FIELD PEND.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS UNTC RADIOBUTTON GROUP OP.

SELECTION-SCREEN COMMENT 4(30) TEXT-012 FOR FIELD UNTC.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS COMP RADIOBUTTON GROUP OP.

SELECTION-SCREEN COMMENT 4(30) TEXT-013 FOR FIELD COMP.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS ALL_E RADIOBUTTON GROUP OP.

SELECTION-SCREEN COMMENT 4(30) TEXT-014 FOR FIELD ALL_E.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK OPSC.

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

SELECT A~VBELN A~ERDAT A~BSTNK A~KUNNR B~SPART B~MATNR B~POSNR B~WERKS B~KWMENG B~KBMENG C~NTGEW C~BRGEW C~GEWEI D~WMENG D~BMENG D~EDATU D~VBELN

INTO CORRESPONDING FIELDS OF TABLE ITSO

FROM VBAK AS A INNER JOIN VBAP AS B ON B~VBELN = A~VBELN

INNER JOIN MARA AS C ON C~MATNR = B~MATNR

INNER JOIN VBEP AS D ON D~WMENG > 0 AND D~VBELN = A~VBELN AND D~POSNR = B~POSNR

WHERE A~VBELN IN SO_ORD AND A~KUNNR IN SO_PARTY AND B~SPART IN DIV AND A~ERDAT IN SO_DATE AND D~EDATU IN S_DATE AND B~MATNR IN IT_M AND B~WERKS = PLANT.

SORT ITSO BY VBELN POSNR.

DATA : V_NETWT LIKE MARA-NTGEW,

V_GRWT LIKE MARA-NTGEW,

V_SOSTAT TYPE C.

LOOP AT ITSO.

if ITSO-bmeng = 0.

V_SOSTAT = 'A'.

ELSEIF ITSO-WMENG <> ITSO-BMENG.

V_SOSTAT = 'B'.

ELSE.

V_SOSTAT = 'C'.

ENDIF.

IF ITSO-GEWEI = 'G'.

V_NETWT = ITSO-NTGEW / 1000.

V_GRWT = ITSO-BRGEW / 1000.

ELSEIF ITSO-GEWEI = 'KG'.

V_NETWT = ITSO-NTGEW.

V_GRWT = ITSO-BRGEW.

ELSEIF ITSO-GEWEI = 'TO'.

V_NETWT = ITSO-NTGEW * 1000.

V_GRWT = ITSO-BRGEW * 1000.

ENDIF.

ITSO-STATUS = V_SOSTAT.

ITSO-SOGWT = V_GRWT * ITSO-WMENG / 1000.

ITSO-SONWT = V_NETWT * ITSO-WMENG / 1000.

ITSO-SINWT = V_GRWT * ITSO-BMENG / 1000.

ITSO-BALGWT = V_GRWT * ( ITSO-WMENG - ITSO-BMENG ) / 1000.

ITSO-BALNWT = V_NETWT * ( ITSO-WMENG - ITSO-BMENG ) / 1000.

ITSO-DISPNWT = V_NETWT * ITSO-BMENG / 1000.

ITSO-BALQTY = ITSO-WMENG - ITSO-BMENG.

SELECT SINGLE NAME1 FROM KNA1 INTO ITSO-PARTYNAME WHERE KUNNR = ITSO-KUNNR.

SELECT SINGLE MAKTX FROM MAKT INTO ITSO-ITEMDESC WHERE MATNR = ITSO-MATNR.

MODIFY ITSO.

ENDLOOP.

PERFORM PRN_SMSTOCK_ALV.

FORM PG_HEADER.

WRITE : 'SALE ORDER STATUS PLANT : ', PLANT.

ENDFORM.

form PRN_SMSTOCK_ALV.

data: w_title type lvc_title,

w_repid type syrepid,

w_comm type slis_formname,

w_status type slis_formname,

x_layout type slis_layout_alv,

t_event type slis_t_event,

t_fieldcat type slis_t_fieldcat_alv,

t_sort type slis_t_sortinfo_alv.

refresh t_fieldcat.

refresh t_event.

refresh t_sort.

clear x_layout.

clear w_title.

perform set_fieldcat2 using:

1 'VBELN' 'VBELN' 'ITSO' space space space space 'S.O.NO.' space space space space space space space t_fieldcat ,

2 'ERDAT' 'ERDAT' 'VBAK' space space space space 'S.O.DATE' space space space space space space space t_fieldcat ,

3 'BSTNK' 'BSTNK' 'ITSO' space space space space 'P.O.NUM.' space space space space space space space t_fieldcat ,

4 'KUNNR' 'KUNNR' 'ITSO' space space space space 'PARTY' space space space space space space space t_fieldcat ,

5 'PARTYNAME' 'PARTYNAME' 'ITSO' '25' space space 'PARTY DESCRIPTION' space space space space space space space space t_fieldcat ,

6 'ITEMDESC' 'ITEMDESC' 'ITSO' '20' space space 'MATERIAL DESCRIPTION'space space space space space space space space t_fieldcat ,

7 'MATNR' 'MATNR' 'ITSO' '10' space 'ITEMID' space space space space space space space space space t_fieldcat ,

8 'POSNR' 'POSNR' 'ITSO' '6' space 'LINE' space space space space space space space space space t_fieldcat ,

9 'BMENG' 'BMENG' 'VBEP' space space space space 'bal.qty' space space space space space space space t_fieldcat .

10 'DISPNWT' 'DISPNWT' 'ITSO' '25' space space 'DISP.NWT' space space space space space space space space t_fieldcat .

x_layout-zebra = 'X'.

perform set_top_page_heading using t_heading t_event.

perform set_events using t_event.

w_status = ''.

w_repid = sy-repid.

w_comm = 'USER_COMMAND'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = w_repid

it_fieldcat = t_fieldcat

is_layout = x_layout

it_sort = t_sort

i_callback_pf_status_set = w_status

i_callback_user_command = w_comm

i_save = 'X'

it_events = t_event

i_grid_title = w_title

tables

t_outtab = ITSO

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. " PRN_SMSTOCK_ALV

form set_top_page_heading using t_heading type slis_t_listheader

t_events type slis_t_event.

data: x_heading type slis_listheader,

x_event type line of slis_t_event.

  • Report title

clear t_heading[].

clear x_heading.

x_heading-typ = 'H'.

x_heading-info = ''(001).

append x_heading to t_heading.

  • Program name

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Program: '.

x_heading-info = sy-repid.

append x_heading to t_heading.

  • User who is running the report

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'User: '.

x_heading-info = sy-uname.

append x_heading to t_heading.

  • Date of execution

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Date: '.

write sy-datum to x_heading-info.

append x_heading to t_heading.

  • Time of execution

clear x_heading.

x_heading-typ = 'S'.

x_heading-key = 'Time: '.

write sy-uzeit to x_heading-info.

append x_heading to t_heading.

  • Top of page event

x_event-name = slis_ev_top_of_page.

x_event-form = 'TOP_OF_PAGE'.

append x_event to t_events.

endform.

&----


*& Form set_events

&----


  • Sets the events for ALV.

  • The TOP_OF_PAGE event is alredy being registered in

  • the set_top_page_heading subroutine.

----


form set_events using t_events type slis_t_event.

data: x_event type line of slis_t_event.

endform.

&----


*& Form set_order

&----


  • Adds an entry to the order table.

----


FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot

t_sort TYPE slis_t_sortinfo_alv.

DATA: x_sort TYPE slis_sortinfo_alv.

CLEAR x_sort.

x_sort-fieldname = p_fieldname.

x_sort-tabname = p_tabname.

x_sort-up = p_up.

x_sort-down = p_down.

x_sort-subtot = p_subtot.

APPEND x_sort TO t_sort.

ENDFORM. "set_order

FORM set_fieldcat2 USING

p_colpos p_fieldname p_ref_fieldname p_ref_tabname

p_outputlen p_noout

p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt

p_hotspot p_showasicon p_checkbox p_edit

p_dosum

t_fieldcat TYPE slis_t_fieldcat_alv.

  • P_JUST.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

CLEAR wa_fieldcat.

  • General settings

wa_fieldcat-fieldname = p_fieldname.

wa_fieldcat-col_pos = p_colpos.

wa_fieldcat-no_out = p_noout.

wa_fieldcat-hotspot = p_hotspot.

wa_fieldcat-checkbox = p_checkbox.

wa_fieldcat-icon = p_showasicon.

wa_fieldcat-do_sum = p_dosum.

IF p_ref_tabname IS INITIAL.

wa_fieldcat-rollname = p_ref_fieldname.

ELSE.

wa_fieldcat-ref_tabname = p_ref_tabname.

IF p_ref_fieldname EQ space.

wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.

ELSE.

wa_fieldcat-ref_fieldname = p_ref_fieldname.

ENDIF.

ENDIF.

  • Set output length.

IF NOT p_outputlen IS INITIAL.

wa_fieldcat-outputlen = p_outputlen.

ENDIF.

  • Set text headers.

wa_fieldcat-seltext_m = p_seltext_l.

wa_fieldcat-seltext_l = p_seltext_l.

wa_fieldcat-seltext_s = p_seltext_l.

IF NOT p_seltext_m IS INITIAL.

wa_fieldcat-seltext_m = p_seltext_m.

ENDIF.

IF NOT p_seltext_l IS INITIAL.

wa_fieldcat-seltext_l = p_seltext_l.

ENDIF.

IF NOT p_seltext_s IS INITIAL.

wa_fieldcat-seltext_s = p_seltext_s.

ENDIF.

IF NOT p_reptext_ddic IS INITIAL.

wa_fieldcat-reptext_ddic = p_reptext_ddic.

ENDIF.

IF NOT p_ddictxt IS INITIAL.

wa_fieldcat-ddictxt = p_ddictxt.

ENDIF.

  • Set as editable or not.

IF NOT p_edit IS INITIAL.

wa_fieldcat-input = 'X'.

wa_fieldcat-edit = 'X'.

ENDIF.

APPEND wa_fieldcat TO t_fieldcat.

ENDFORM. "set_fieldcat2

======================== Subroutines called by ALV ================

&----


*& Form top_of_page

&----


  • Called on top_of_page ALV event.

  • Prints the heading.

----


form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

  • i_logo = <<If you want to set a logo, please,

  • uncomment and edit this line>>

it_list_commentary = t_heading.

endform. " alv_top_of_page

form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

endform. "user_command