Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

I had developed this code but the output was gone into the dump

I had developed this code but I am getting error at the output.Can you help me what I done was wrong.

&----


*& Report ZNEELIMA1

*&

&----


*&

*&

&----


REPORT ZNEELIMA2.

TABLES : VBAK, "Sales Document Headerdata

VBAP. "Sales Document item Data

&***********************************************************************

  • Type POOL Declaration

&************************************************************************

TYPE-POOLS : SLIS.

&************************************************************************

  • Types Declaration

&************************************************************************

TYPES : BEGIN OF TY_VBAK,

KUNNR TYPE KUNNR, "Sold-to party

VBELN TYPE VBELN, "Sales Document

VKBUR TYPE VKBUR, "Sales Office

VKGRP TYPE VKGRP, "Sales Group

END OF TY_VBAK.

TYPES : BEGIN OF TY_VBAP,

VBELN TYPE VBELN, "SALES DOCUMENT NUMBER

ERDAT TYPE ERDAT, "Date on Which Record Was Created

ERNAM TYPE ERNAM, "Name of Person who Created the Object

ARKTX TYPE ARKTX, "Short text for sales order item

END OF TY_VBAP.

TYPES : BEGIN OF TY_FINAL,

KUNNR TYPE KUNNR, "Sold-to party

VBELN TYPE VBELN, "Sales Document

VKBUR TYPE VKBUR, "Sales Office

VKGRP TYPE VKGRP, "Sales Group

ARKTX TYPE ARKTX, "Short text for sales order item

ERDAT TYPE ERDAT, "Date on Which Record Was Created

ERNAM TYPE ERNAM, "Name of Person who Created the Object

END OF TY_FINAL.

DATA : BEGIN OF ITAB OCCURS 0,

TNAME TYPE c, "Technical name

LPRC TYPE P DECIMALS 2, "LIST Price

NSPC TYPE P DECIMALS 2, "Normal sell price

OVAL TYPE P DECIMALS 2, "order value

ASPC TYPE P DECIMALS 2, "Actual sell Price

DISC TYPE P DECIMALS 2, "Discount

DVAL TYPE P DECIMALS 2, "Discount Value

COGS TYPE P DECIMALS 2, "Cost of goods sold

AMAR TYPE P DECIMALS 2, "Actual margin

AMRP TYPE P DECIMALS 2, "Actual margin%

end of ITAB.

TYPES : BEGIN OF TY_FIELDCAT,

IS_LAYOUT TYPE SLIS_LAYOUT_ALV,

I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

I_EVENTS TYPE SLIS_T_EVENT,

END OF TY_FIELDCAT.

&*******************************************************************************

  • workarea declaration

&*******************************************************************************

DATA : WA_VBAK TYPE TY_VBAK,

WA_VBAP TYPE TY_VBAP,

WA_FINAL TYPE TY_FINAL,

WA_FIELDCAT TYPE TY_FIELDCAT.

&----


*& Internal table declaration

&----


  • Internal table to store VBAP data

DATA: IT_VBAP LIKE STANDARD TABLE OF WA_VBAP INITIAL SIZE 0,

*Internal table to store VBAK data

IT_VBAK LIKE STANDARD TABLE OF WA_VBAK INITIAL SIZE 0,

*internal table to store final data

IT_FINAL LIKE STANDARD TABLE OF WA_FINAL INITIAL SIZE 0.

*Internal table to store ITAB data

  • IT_ITAB LIKE STANDARD TABLE OF WA_ITAB INITIAL SIZE 0.

*INTERNAL TABLE FOR FIELDCATALOG

DATA : TY_FIELDCAT LIKE STANDARD TABLE OF WA_FIELDCAT INITIAL SIZE 0.

DATA : IS_LAYOUT TYPE SLIS_LAYOUT_ALV,

I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

I_FIELDCAT_LOG TYPE SLIS_T_FIELDCAT_ALV,

FIELDCAT TYPE SLIS_FIELDCAT_ALV,

I_EVENTS TYPE SLIS_T_EVENT,

EVENTS TYPE SLIS_ALV_EVENT,

ALV_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

GS_LINE TYPE SLIS_LISTHEADER,

ALV_EVENTS TYPE SLIS_T_EVENT,

ALV_VARIANT TYPE DISVARIANT,

ALV_TITLE TYPE LVC_TITLE,

ALV_SORT TYPE SLIS_T_SORTINFO_ALV,

CSORT TYPE SLIS_SORTINFO_ALV.

&----


&--


SELECTION-SCREEN--

&----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.

PARAMETERS : P_VKBUR LIKE VBAK-VKBUR. " For single input

SELECT-OPTIONS : S_KUNNR FOR VBAK-KUNNR,

S_VBELN FOR VBAK-VBELN,

S_VKGRP FOR VBAK-VKGRP,

S_ERDAT FOR VBAP-ERDAT,

S_ERNAM FOR VBAP-ERNAM,

S_ARKTX FOR VBAP-ARKTX.

SELECTION-SCREEN END OF BLOCK B1.

&----


&--


START-OF-SELECTION--

&----


START-OF-SELECTION.

PERFORM SELECT_DATA.

&--


FIELD CATALOG--

PERFORM BUILD_FIELDCATALOG.

&--


END-OF-SELECTION--

END-OF-SELECTION.

PERFORM DISPLAY_DATA.

&----


*& Form SELECT_DATA

&----


  • text

----


FORM SELECT_DATA .

select

kunnr "Sold to Party

vbeln "Sales Document

vkbur "Sales Office

vkgrp "Sales Group

from vbak into table it_vbak where vkbur = p_vkbur

and kunnr in s_kunnr

and vbeln in s_vbeln

and vkgrp in s_vkgrp.

if sy-subrc = 0.

sort it_vbak by kunnr vbeln vkbur vkgrp.

endif.

if it_vbak is not initial.

SELECT

VBELN

ERDAT

ERNAM

ARKTX

FROM VBAP INTO TABLE IT_VBAP FOR ALL ENTRIES IN IT_VBAK

WHERE VBELN = IT_VBAK-VBELN AND ERDAT IN S_ERDAT.

endif.

&----


  • Read data

&----


LOOP AT IT_VBAP INTO WA_VBAP.

READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN = WA_VBAP-VBELN.

WA_FINAL-KUNNR = WA_VBAK-KUNNR.

WA_FINAL-VBELN = WA_VBAK-VBELN.

WA_FINAL-VKBUR = WA_VBAK-VKBUR.

WA_FINAL-VKGRP = WA_VBAK-VKGRP.

WA_FINAL-ERDAT = WA_VBAP-ERDAT.

WA_FINAL-ERNAM = WA_VBAP-ERNAM.

WA_FINAL-ARKTX = WA_VBAP-ARKTX.

APPEND WA_FINAL TO IT_FINAL.

ENDLOOP.

ENDFORM. " SELECT_DATA

&----


*& Form DISPLAY_DATA

&----


FORM DISPLAY_DATA .

*******************FUNCTION MODULE*************************************

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 = 'SALES PRICE CHANGE REPORT'

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = I_FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

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

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_DATA

&----


*& Form BUILD_FIELDCATALOG

&----


----


FORM BUILD_FIELDCATALOG .

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'TNAME'.

FIELDCAT-SELTEXT_M = 'Technical name'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'KUNNR'.

FIELDCAT-SELTEXT_M = 'Sold-to party'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'VBELN'.

FIELDCAT-SELTEXT_M = 'Sales Document Number'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'VKBUR'.

FIELDCAT-SELTEXT_M = 'Sales Offiece'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'VKGRP'.

FIELDCAT-SELTEXT_M = 'Sales Group'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'LPRC'.

FIELDCAT-SELTEXT_M = 'List Price'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'NSPC'.

FIELDCAT-SELTEXT_M = 'Normal sell price'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'OVAL'.

FIELDCAT-SELTEXT_M = 'order value'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'ASPC'.

FIELDCAT-SELTEXT_M = 'Actual sell Price'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'DISC '.

FIELDCAT-SELTEXT_M = 'Discount'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'DVAL'.

FIELDCAT-SELTEXT_M = 'Discount Value'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'COGS'.

FIELDCAT-SELTEXT_M = 'Cost of goods sold'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'AMAR'.

FIELDCAT-SELTEXT_M = 'Actual margin'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'ITAB'.

FIELDCAT-FIELDNAME = 'AMRP'.

FIELDCAT-SELTEXT_M = 'Actual margin%'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'P'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'ERDAT'.

FIELDCAT-SELTEXT_M = 'Date of Creation'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FINAL'.

FIELDCAT-FIELDNAME = 'ERNAM'.

FIELDCAT-SELTEXT_M = 'The Person who created'.

FIELDCAT-JUST = 'L'.

FIELDCAT-KEY = 'X'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-TABNAME = 'IT_FIANL'.

FIELDCAT-FIELDNAME = 'ARKTX'.

FIELDCAT-SELTEXT_M = 'Short text for sales order item'.

FIELDCAT-JUST = 'L'.

FIELDCAT-DATATYPE = 'C'.

APPEND FIELDCAT TO I_FIELDCAT.

CLEAR FIELDCAT.

ENDFORM. " BUILD_FIELDCATALOG

Tags:
Not what you were looking for? View more on this topic or Ask a question