Skip to Content

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

alv report

hello sir/medam

thia is my vender report.i m using two table and displaye thro. alv but not working.Only prob. in run time error.

but without alv working fine.

plz help me.

&----


*& Report ZVENDER_OP_BA2

*&

&----


*&

*&

&----


REPORT ZVENDER_OP_BA2.

TYPE-POOLS:SLIS.

tables: bsak,bseg.

data: begin of itab occurs 0,

budat like bsak-budat, "postind date.

bldat like bsak-bldat, "docuent date.

dmbtr like bsak-dmbtr, "amount.

xblnr like bsak-xblnr, "refrance no.

  • bukrs1 like bsak-bukrs, "company code.

  • lifnr1 LIKE bsak-lifnr, "vender code

SGTXT like bseg-sgtxt, "text

GSBER like bseg-gsber, "buissness area.

SHKZG like bseg-shkzg, "dabit/credit card

BELNR like bseg-belnr, "document no.

WERKS like bseg-werks, "currency key

BUKRS like bseg-bukrs, "company code.

LIFNR like bseg-lifnr, "vender code

end of itab.

DATA : BEGIN OF ITAB1 OCCURS 0,

SGTXT like bseg-sgtxt,

GSBER like bseg-gsber,

SHKZG like bseg-shkzg,

BELNR like bseg-belnr,

WERKS like bseg-werks,

BUKRS like bseg-bukrs,

END OF ITAB1.

DATA : BEGIN OF ITAB2 OCCURS 0,

budat like bsak-budat,

bldat like bsak-bldat,

dmbtr like bsak-dmbtr,

xblnr like bsak-xblnr,

bukrs like bsak-bukrs,

lifnr LIKE bsak-lifnr,

END OF ITAB2.

SELECT SGTXT GSBER SHKZG BELNR WERKS BUKRS FROM BSEG INTO

(ITAB1-SGTXT, ITAB1-GSBER, ITAB1-SHKZG, ITAB1-BELNR, ITAB1-WERKS,

ITAB1-BUKRS).

ITAB-SGTXT = ITAB1-SGTXT.

ITAB-GSBER = ITAB1-GSBER.

ITAB-SHKZG = ITAB1-SHKZG.

ITAB-BELNR = ITAB1-BELNR.

ITAB-WERKS = ITAB1-WERKS.

ITAB-BUKRS = ITAB1-BUKRS.

SELECT single BUDAT BLDAT DMBTR XBLNR BUKRS LIFNR FROM BSAK INTO

(ITAB2-BUDAT,ITAB2-BLDAT,ITAB2-DMBTR,ITAB2-XBLNR,ITAB2-BUKRS,

ITAB2-LIFNR)

WHERE

BUKRS = ITAB-BUKRS AND

LIFNR = ITAB-LIFNR.

*READ TABLE ITAB2 WITH KEY BUKRS = ITAB-BUKRS LIFNR = ITAB-LIFNR.

IF SY-SUBRC = 0.

ITAB-BUDAT = ITAB2-BUDAT.

ITAB-BLDAT = ITAB2-BLDAT.

ITAB-DMBTR = ITAB2-DMBTR.

ITAB-XBLNR = ITAB2-XBLNR.

ENDIF.

APPEND ITAB.

ENDSELECT.

    • ENDSELECT.

*LOOP AT ITAB.

*WRITE : / ITAB-SGTXT,' ', ITAB-GSBER,' ',

*ITAB-BELNR,' ' , ITAB-WERKS,' ',ITAB-SHKZG,' ',ITAB-LIFNR

*,' ',ITAB-BUKRS,' ',ITAB-BUDAT,ITAB-BLDAT,ITAB-DMBTR,ITAB-XBLNR

*.

*ENDLOOP.

*

DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

START-OF-SELECTION.

PERFORM BUILD_FIELDCATALOG.

PERFORM DISPLAY_ALV_REPORT.

FORM BUILD_FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'BUDAT'.

FIELDCATALOG-SELTEXT_M = 'Posting date'.

FIELDCATALOG-COL_POS = 1.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'BLDAT'.

FIELDCATALOG-SELTEXT_M = 'Document Date'.

FIELDCATALOG-COL_POS = 2.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'BELNR'.

FIELDCATALOG-SELTEXT_M = 'Document Number '.

FIELDCATALOG-COL_POS = 3.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'GSBER'.

FIELDCATALOG-SELTEXT_M = 'Business area '.

FIELDCATALOG-COL_POS = 4.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'XBNLR'.

FIELDCATALOG-SELTEXT_M = 'Ref doc. n0. '.

FIELDCATALOG-COL_POS = 5.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'SHKZG'.

FIELDCATALOG-SELTEXT_M = 'Debit/credit'.

FIELDCATALOG-COL_POS = 6.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'DMBTR'.

FIELDCATALOG-SELTEXT_M = 'Amount'.

FIELDCATALOG-COL_POS = 7.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'WERKS'.

FIELDCATALOG-SELTEXT_M = 'currency'.

FIELDCATALOG-COL_POS = 8.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'SGTXT'.

FIELDCATALOG-SELTEXT_M = 'Text'.

FIELDCATALOG-COL_POS = 9.

FIELDCATALOG-KEY = 'X'.

APPEND FIELDCATALOG TO FIELDCATALOG.

CLEAR FIELDCATALOG.

endform.

FORM DISPLAY_ALV_REPORT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

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

IT_FIELDCAT = FIELDCATALOG[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = ' X'

  • 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 = ITAB

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.

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