cancel
Showing results for 
Search instead for 
Did you mean: 

Hi friends can any one share sap script?

Former Member
0 Kudos

Hi friends can any one share me the procedure to create sap script with table that has to be displayed....

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

i am sending script program you go through it.

types:begin of st_lfa1,

lifnr type lfa1-lifnr,

name1 type lfa1-name1,

land1 type lfa1-land1,

ort01 type ort01,

regio type regio,

end of st_lfa1.

types:begin of st_ekko,

ebeln type ekko-ebeln,

bukrs type ekko-bukrs,

aedat type ekko-aedat,

ernam type ekko-ernam,

bstyp type ekko-bstyp,

lifnr type ekko-lifnr,

end of st_ekko.

types:begin of st_ekpo,

ebeln type ekpo-ebeln,

ebelp type ekpo-ebelp,

loekz type ekpo-loekz,

aedat type ekpo-aedat,

matnr type ekpo-matnr,

netwr type ekpo-netwr,

end of st_ekpo.

&--


internal table,work area declaration--

data:wa_lfa1 type st_lfa1,

it_lfa1 type standard table of st_lfa1,

wa_ekko type st_ekko,

it_ekko type standard table of st_ekko,

wa_ekpo type st_ekpo,

it_ekpo type standard table of st_ekpo.

&--


data declaration--

data:total type ekpo-netwr,

v_ebeln type ekko-ebeln.

data: v_item(20) type c.

&--


parameter for purchase document number--

selection-screen begin of block b1 with frame title text-001.

parameters p_purdoc like v_ebeln.

selection-screen end of block b1.

start-of-selection.

perform get_data_from_ekko.

perform get_data_from_lfa1.

perform get_data_from_ekpo.

&--


grand total--

loop at it_ekpo into wa_ekpo.

total = total + wa_ekpo-netwr.

clear wa_ekpo.

endloop.

&--


open form--

call function 'OPEN_FORM'

exporting

device = 'PRINTER'

form = 'Z_50886_VENDOR'

language = sy-langu

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.

&--


write form for header details--

read table it_ekko into wa_ekko index 1.

call function 'WRITE_FORM'

exporting

element = 'HEAD'

window = 'HEADER'

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.

&--


write form for item details--

loop at it_ekpo into wa_ekpo.

concatenate wa_ekko-ebeln wa_ekpo-ebelp into v_item.

call function 'WRITE_FORM'

exporting

element = 'ITEM'

window = 'MAIN'

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.

&--


write form for vendor details--

read table it_lfa1 into wa_lfa1 index 1.

call function 'WRITE_FORM'

exporting

element = 'VENDOR'

window = 'ADDRESS'

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.

&--


write form for grand total--

call function 'WRITE_FORM'

exporting

window = 'TOTAL'

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.

&--


close form--

call function 'CLOSE_FORM'

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.

&----


*& Form get_data_from_ekko

&----


form get_data_from_ekko .

select ebeln

bukrs

aedat

ernam

bstyp

lifnr

from ekko into table it_ekko where ebeln = p_purdoc.

endform. " get_data_from_ekko

&----


*& Form get_data_from_lfa1

&----


form get_data_from_lfa1 .

if not it_ekko[] is initial.

select lifnr

name1

land1

ort01

regio

from lfa1 into table it_lfa1 for all entries in it_ekko where

lifnr = it_ekko-lifnr.

endif.

endform. " get_data_from_lfa1

&----


*& Form get_data_from_ekpo

&----


form get_data_from_ekpo .

if not it_ekko[] is initial.

select ebeln

ebelp

loekz

aedat

matnr

netwr

from ekpo into table it_ekpo

where ebeln = p_purdoc.

endif.

you also go through these links.

http://www.sap-img.com/sapscripts/create-scripts-of-your-own-using-standard-scripts.htm

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm

http://www.sap-img.com/ts003.htm

http://www.sap-img.com/sapscripts.htm

Former Member
0 Kudos

Hi,

Go thru the below link:

http://smoschid.tripod.com/How_to_do_things_in_SAP/How_To_Create_A_SAPSCRIPT_Form/How_to_Create_SAPS...

It has step by step approach...

Regards,

Narendra.