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: 

sap script

Former Member
0 Kudos

dear experts,

this is my driver program for the sap script.

but when i execute this i am able to display the form. please tell me where i had gone wrong.

TABLES: BSEG,BKPF,SKAT.

DATA : BEGIN OF I_BKPF OCCURS 0,

BSTAT LIKE BKPF-BSTAT,

XREVERSAL LIKE BKPF-XREVERSAL,

BELNR LIKE BKPF-BELNR,

BLDAT LIKE BKPF-BLDAT,

BUDAT LIKE BKPF-BUDAT,

BKTXT LIKE BKPF-BKTXT,

BVORG LIKE BKPF-BVORG,

BLART LIKE BKPF-BLART,

TCODE LIKE BKPF-TCODE,

USNAM LIKE BKPF-USNAM,

PPNAM LIKE BKPF-PPNAM,

END OF I_BKPF.

DATA :BEGIN OF I_BSEG OCCURS 0,

DOCLN LIKE BSEG-DOCLN,

BUKRS LIKE BSEG-BUKRS,

HKONT LIKE BSEG-HKONT,

PRCTR LIKE BSEG-PRCTR,

PROJK LIKE BSEG-PROJK,

KOSTL LIKE BSEG-KOSTL,

WRBTR LIKE BSEG-WRBTR,

DMBTR LIKE BSEG-DMBTR,

BSCHL LIKE BSEG-BSCHL,

MWSKZ LIKE BSEG-MWSKZ,

VBUND LIKE BSEG-VBUND,

PSWSL LIKE BSEG-PSWSL,

END OF I_BSEG.

DATA : BEGIN OF I_FINTAB OCCURS 0,

DOCLN LIKE BSEG-DOCLN,

BUKRS LIKE BSEG-BUKRS,

HKONT LIKE BSEG-HKONT,

PRCTR LIKE BSEG-PRCTR,

PROJK LIKE BSEG-PROJK,

KOSTL LIKE BSEG-KOSTL,

WRBTR LIKE BSEG-WRBTR,

DMBTR LIKE BSEG-DMBTR,

BSCHL LIKE BSEG-BSCHL,

MWSKZ LIKE BSEG-MWSKZ,

VBUND LIKE BSEG-VBUND,

PSWSL LIKE BSEG-PSWSL,

SGTXT LIKE BSEG-SGTXT,

BSTAT LIKE BKPF-BSTAT,

XREVERSAL LIKE BKPF-XREVERSAL,

BELNR LIKE BKPF-BELNR,

BLDAT LIKE BKPF-BLDAT,

BUDAT LIKE BKPF-BUDAT,

BKTXT LIKE BKPF-BKTXT,

BVORG LIKE BKPF-BVORG,

BLART LIKE BKPF-BLART,

TCODE LIKE BKPF-TCODE,

USNAM LIKE BKPF-USNAM,

PPNAM LIKE BKPF-PPNAM,

END OF I_FINTAB.

DATA : V_TOP TYPE C,

V_TEMP TYPE C VALUE 'X'.

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

PARAMETERS: P_BUKRS LIKE BKPF-BUKRS.

SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.

*PERFORM GET_DATA.

PERFORM OPEN_FORM.

PERFORM WRITE_FORM.

PERFORM CLOSE_FORM.

&----


*& FORM GET_DATA

&----


*FORM GET_DATA.

FORM SUB_FORM1 TABLES INTAB STRUCTURE ITCSY OUTTAB STRUCTURE ITCSY.

*SELECT BUKRS

  • BELNR

  • GJAHR

  • FROM BKPF INTO TABLE I_BKPF WHERE BSTAT =

*SELECT SINGLE BELNR FROM BKPF INTO G_BELNR

  • WHERE BLART = G_BLART

  • AND BLDAT = G_BLDAT

  • AND TCODE = G_TCODE

  • AND BUDAT = G_BUDAT

  • AND USNAM = G_USNAM

  • AND BKTXT = G_BKTXT

  • AND PPNAM = G_PPNAM

  • AND BVORG = G_BVORG.

DATA: G_BELNR LIKE BKPF-BELNR,

G_BLDAT LIKE BKPF-BLDAT,

G_BUDAT LIKE BKPF-BUDAT,

G_BLART LIKE BKPF-BLART,

G_BVORG LIKE BKPF-BVORG,

G_BKTXT LIKE BKPF-BKTXT,

G_TCODE LIKE BKPF-TCODE,

G_USNAM LIKE BKPF-USNAM,

G_PPNAM LIKE BKPF-PPNAM.

SELECT BELNR

BLDAT

BUDAT

BKTXT

BVORG

BLART

TCODE

USNAM

PPNAM INTO I_BKPF FROM BKPF WHERE BELNR = G_BELNR.

ENDSELECT.

ENDFORM.

FORM SUB_FORM2 TABLES INTAB STRUCTURE ITCSY OUTTAB STRUCTURE ITCSY.

DATA: G_BELNR LIKE BSEG-BELNR,

G_DOCLN LIKE BSEG-DOCLN,

G_BUKRS LIKE BSEG-BUKRS,

G_HKONT LIKE BSEG-HKONT,

G_PRCTR LIKE BSEG-PRCTR,

G_PROJK LIKE BSEG-PROJK,

G_KOSTL LIKE BSEG-KOSTL,

G_WRBTR LIKE BSEG-WRBTR,

G_DMBTR LIKE BSEG-DMBTR,

G_BSCHL LIKE BSEG-BSCHL,

G_MWSKZ LIKE BSEG-MWSKZ,

G_VBUND LIKE BSEG-VBUND,

G_PSWSL LIKE BSEG-PSWSL.

SELECT DOCLN

BUKRS

HKONT

PRCTR

PROJK

KOSTL

WRBTR

DMBTR

BSCHL

MWSKZ

VBUND

PSWSL INTO I_BSEG FROM BSEG WHERE BELNR = G_BELNR.

ENDSELECT.

ENDFORM.

*ENDFORM. "GET DATA

&----


*& FORM OPEN_FORM

&----


FORM OPEN_FORM.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZZ_FIGL_JOURNAL'

LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

INVALID_FAX_NUMBER = 8

MORE_PARAMS_NEEDED_IN_BATCH = 9

SPOOL_ERROR = 10

CODEPAGE = 11

OTHERS = 12

.

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

&----


*& WRITE_FORM

&----


FORM WRITE_FORM.

LOOP AT I_FINTAB.

V_TOP = 'Y'.

AT NEW BELNR.

V_TOP = 'X'.

ENDAT.

READ TABLE I_FINTAB WITH KEY BELNR = I_FINTAB-BELNR.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

ENDFORM. "WRITE_FORM

&----


*& FORM CLOSE_FORM

&----


FORM CLOSE_FORM.

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5

OTHERS = 6

.

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.

*END-OF-SELECTION.

this is the line editor code i have written.

perform sub_form2 in program zsap_driver

using &bkpf-belnr&

changing &g_docln&

changing &g_bukrs&

changing &g_hkont&

changing &g_prctr&

changing &g_progk&

changing &g_kostl&

changing &g_wrbtr&

changing &g_dmbtr&

changing &g_bschl&

changing &g_mwskz&

changing &g_vbund&

changing &g_pswsl&

end perform.

regards,

siri.

1 REPLY 1

Former Member
0 Kudos

Hi,

use this

*

DR_PARAM-TDPREVIEW = 'X'. "Druckvoschau

*

CALL FUNCTION 'OPEN_FORM'

EXPORTING

...

OPTIONS = DR_PARAM

...

Regard, dieter