cancel
Showing results for 
Search instead for 
Did you mean: 

Program code in SAPScript

Former Member
0 Kudos

Hi all,

I'm using program RFKORD50 to print customer invoices. For this I have made a copy of the form F140_DOCU_EXC_02 (Customer Invoice), and added this to the form set in RFKORD50.

I would like to add some additional information in this Z-form, data which is not passed from the application program. Is it possible to add some program lines to the Z-form which can retrieve the additional data, or handle this in any other way without changing the application program itself?

All helpful answers will be rewarded!

Regards,

M.V.

Accepted Solutions (1)

Accepted Solutions (1)

former_member196280
Active Contributor
0 Kudos

You can use subroutine call inside your Form for getting additional information... there is no need of modify your driver program.

Ex:

/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>

/:USING &<field name>&

/:CHANGING &<field name1&

/:ENDPERFORM

Then create subroutine pool program and you have to write the code.

FORM ><subroutine name> tables int_cond structure itcsy

outt_cond structure itcsy.

data : value(20), value1(20). "do your own declarations

Read int_cond table index 1.

value = int_cond-value.

value1 = value1 + value.

Read outt_cond table index 1.

outt_cond-value = value1.

Modify outt_cond index 1.

ENDFORM.

Just rough idea given above.

Regards,

Sairam

Former Member
0 Kudos

Hi Sairam,

Thanks for your reply - this was very helpful!

The subroutine returns an itab of text lines:

/:PERFORM <Subroutine name> IN PROGRAM <subroutine prog name> 
/:USING &<field>& 
/:CHANGING &<table>&
/:ENDPERFORM

How do I...?

a) declare the internal table in the script code?

b) loop and display the contents of this itab in the script code?

I will reward more points!

Regards,

M.V.

former_member196280
Active Contributor
0 Kudos

I am sorry to say that SAPscript sub-routine cannot return more then one value, and also there is no option of looping internal table inside SAPscript. Only way to acheive this(i.e multiple values) using SAPscript is to modify the driver program. Now, no other option available for you except to modify the print program.

Note: this kind of scenarios can be overcome in smartforms(i.e without modifying the driver program)..

Close the thread once your question is answered.

Regards,

SaiRam

Former Member
0 Kudos

Hi,

While the ABAP subroutine considers this a table, the SAPscript does not, so you don't need to declare a table in the form, just list the fields. E.g.

/:PERFORM <Subroutine name> IN PROGRAM <subroutine prog name> 
/:USING &FIELD1& &FIELD2&  etc...
/:CHANGING &FIELD_A& &FIELD_B& etc...
/:ENDPERFORM

Regards,

Nick

Former Member
0 Kudos

Hi Nick,

Thank you, that was very useful information!

The fields I need to change

/:CHANGING &FIELD_A& &FIELD_B&

...needs to be <b>declared</b> in the script, how do I do this?

Regards,

M.V.

Former Member
0 Kudos

Use;

/: DEFINE &FIELD_A&
/: DEFINE &FIELD_B&

Regards,

Nick

Former Member
0 Kudos

Hi,

Can you please provide me with the full syntax for DEFINE? &FIELD& is of type CHAR, length 10.

Thanks

Former Member
0 Kudos

Hi,

Well, the CHAR element is the default, SAPscript can only define character type fields. The full syntax is

/: DEFINE &FIELD& = 'value'

Now you'll actually be setting the value in your ABAP, and this will dictate the length, so in theory you could use,

/: DEFINE &FIELD& = '1234567890'

or I guess

/: DEFINE &FIELD& = ' '

It may be worth a bit of trial and error to see which makes most sense.

Regards,

Nick

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Certainly possible. Take a look at the online help for the SAPscript command PERFORM which explains this in better detail than I possibly could.

Regards,

Nick