cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a table in SAPscript

Former Member
0 Kudos

Hello,

I am quite new at SAPscript, and cannot figure out how to create a table in my main window.

I have read this forum post : but am having problems with the way to fill in tabs, so if someone could help me understand better I would be very grateful.

i need to create the following scenario:


------------------------------------------------
|ITEM  |MATERIAL    |QTY     |PRICE   |CURRENCY | <-Headr
------------------------------------------------
| xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
| xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
| xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
| xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | .
| xxxx |xxxxx       |xxxx    |xxxx    |xxxx     | <-Item
-------------------------------------------------
                 Total Amount xxxx

I have created a paragraph format PF with all the necessary tabs.

1) How do I create the table and the dividing lines ?

In the line editor I typed

<b>/E</b> TABLE

<b>PF</b> Item,,Material,,Quantity,,Price,,Currency

(will these be translated when I translate the form with the SE63 transaction? Or should I put the technical name for them, for example: &BKPF-BELNR&,,&BKPF-UZEGF&,,etc ?)

what is the use of the <b>/E</b> TABLE ? All it does is print "/E TABLE" in my print preview... is this normal or did I forget to do something ?

2) now in the Items, how do I input the different elements ?

If I just type

<b>PF</b> &BSEG-BSHL&,,&BSEG-BSGY&,,etc will I get as many lines as I have items ?

I read on a forum that I need to type itab, but how do I syntax it so that it works with the technical info of a field?

&itab-BSEG-BSHL& doesn't work, I get an error message saying "unknow symbol itab-BSEG-BSHL"

Thank you in advance

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Micol,

Create a window for the below ( Header window )

-


|ITEM |MATERIAL |QTY |PRICE |CURRENCY | <-Headr

-


<b>In text elements of this window write this

PH ,,ITEM,,MATERIAL,,QTY,,PRICE,,CURRENCY

Here PH is a paragraph format give appropriate tabs.</b>

| xxxx |xxxxx |xxxx |xxxx |xxxx | <-Item

| xxxx |xxxxx |xxxx |xxxx |xxxx | .

| xxxx |xxxxx |xxxx |xxxx |xxxx | .

| xxxx |xxxxx |xxxx |xxxx |xxxx | .

| xxxx |xxxxx |xxxx |xxxx |xxxx | <-Item

-


Assume the fields are

Item - itab-item

material - itab-material

quantity - itab-qty

price - itab-price

currency - itab-currency

<b>In text elements of main window write

/E TABLE

PI ,,&ITAB-ITEM&,,&ITAB-MATNR&,,&ITAB-QTY&

,,&ITAB-PRICE&,,&ITAB-CURRENCY&

</b>

In u r driver program

loop at itab

Call function 'WRITE_FORM'.

  • under element take 'TABLE'

  • window 'MAIN'

-


endloop

-


Former Member
0 Kudos

Hi,

Sorry for my stupid questions, but I am really very new at this...

I know what my driver program is (ZRFKORD30) but how do I access it in order to modify it?

If type &ITAB-ITEM& etc, when I do a check in order to do a print preview, I get an error saying "unknow symbol ITAB-ITEM"...

Is PI just anoter tabbed paragraph format, the same as your PH ?

How will the program know what information goes where in the table if I don't use values like &BSEG-KSCHL& ?

Thanks,

Micol

Former Member
0 Kudos

Hi,

If you are doing a Custome development, you need to write a program for that one, or if you are changing the Standard one, then there will be a Driver program.

lets say you are doing it for a Custome program, then create a program. for this one you need to write the Open_from, Start_from, Write_form, Close_from and End_form,

in between the Start_from and Close_from, you can write as many write_froms as you can, here you need to get the data by writing the selects or if the data is there in the table BSEG that is fine, after that as i said create the elemnts for the Header and create elemnt for the item data which needs to show in tha table.

and write it in the program as i said in the above

How would I modify this sample loop code for it to fit me?

the below is for the header, this should be printer only once, so we won't use the Loop statment over here

<b>

CALL FUNCTION 'WRITE_FORM'

exporting

element 'HEADER'

Window 'MAIN'.

.</b>

the below is for the iteam data, which will be printed in the table

<b>LOOP at ITAB.

CALL FUNCTION 'WRITE_FORM'

exporting

element 'TABLE'

Window 'MAIN'.

ENDLOOP.</b>

Former Member
0 Kudos

Hi,

You created a element for the header, this wil be printed, and you need to call this in the Driver program, just call the function WRITE_FORM and pass the windoe name and the Element name

<b>/E TABLE

PF Item,,Material,,Quantity,,Price,,Currency</b>

for the item data, you have writen the below statment, i do not think that the data won't come directly from the tables, in the runtime the Structure will contain the data, so look at the Structure and give that name instead of the BSEG.

<b>/E ITEM_DATA

PF &BSEG-BSHL&,,&BSEG-BSGY&,,</b>

after that ..

loop that Structure

Call the Element(ITEM_DATA) whcih you created for that titem data, this is there in the loop so it will be printed as a table format.

endloop.

in the loop itself, caliculate the total amount, ater this element

/E ITAM_DATA, write that field in the SCRIPT ..

Regards

Sudheer

Former Member
0 Kudos

I'm sorry, I don't quite understand everything you are saying ...

Where do I find the driver program?

Where do I find the Structure?

How would I modify this sample loop code for it to fit me?

LOOP at ITAB.
CALL FUNCTION 'WRITE_FORM'
   exporting
       element 'TABLE'.
ENDLOOP.

Thanks,

Micol