cancel
Showing results for 
Search instead for 
Did you mean: 

Printing Serial numbers in a script.

Former Member
0 Kudos

Hi friends,

I want to print serial number for the line items in the main window of a script, Please help me regarding this, if possible give me the sample code.

I want to print like this

sl.no. material no.

1. 100-100

2. 100-101

thanks in advance,

Arundhathi.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

for this just keep a counter which will update it by 1 everytime a matyerail prints .

for ex.

sr_no. = sr_no. + 1 .

Thanks

Rohit

Reward if helpfull

Former Member
0 Kudos

Hi Rohit,

I got your point, but my doudt is how to do it in sapscript.

The print program what i am using is the standard print program, i cant make any change in the standard print program.

Thanks in advance,

Arundhathi.

santhosh_shanig
Explorer
0 Kudos

HI

You can use &SAPSCRIPT-COUNTER_1&

And you can increment the counter and display serial numbers.

For INCREMENTING.

&SAPSCRIPT-COUNTER_1(+)& " Increases by 1

Regards

Santhosh

Former Member
0 Kudos

Hi

to increase a sapscript counter you put a symbol in front

Like for example

You can increase or decrease the value of a SAPSCRIPT-COUNTER_x (x=0.. 9) counter variable by 1, before the current counter value is printed.

Syntax:

&SAPSCRIPT-COUNTER_x(+)& Increases by 1 the contents

of the counter variable x

(x=0.. 9)

&SAPSCRIPT-COUNTER_x(-)& Decreases by 1 the contents

of the counter variable x

(x=0.. 9)

If you want to change the value of a counter variable without actually printing the new value, use this formatting option together with an additional option to set the output length to 0 (see above). If you want to set a counter variable to some specific value, use the DEFINE control command.

Assume that &SAPSCRIPT-COUNTER_1& initially has the value 2.

&SAPSCRIPT-COUNTER_1& -> 2

&SAPSCRIPT-COUNTER_1(+)& -> 3

&SAPSCRIPT-COUNTER_1(-)& -> 2

&SAPSCRIPT-COUNTER_1(-)& -> 1

&SAPSCRIPT-COUNTER_1(+0)& ->

&SAPSCRIPT-COUNTER_1(+)& -> 3

Or in your report give this coding

FORM increase_line_count TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

DATA: line_count TYPE i.

READ TABLE in_par WITH KEY 'COUNTER'.

IF sy-subrc = 0.

*---Increase Counter

line_count = in_par-value + 1.

*---Set Counter

READ TABLE out_par WITH KEY 'COUNTER'.

IF sy-subrc = 0.

out_par-value = line_count.

MODIFY out_par INDEX sy-tabix.

ENDIF.

ENDIF.

ENDFORM. " INCREASE_LINE_COUNT

Then in your main window call this form as:

/: PERFORM INCREASE_LINE_COUNT IN PROGRAM ZPROGRAMNAME

/: USING &COUNTER&

/: CHANGING &COUNTER&

/: ENDPERFORM

Regards

Pavan