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: 

Perform in script

Former Member
0 Kudos

Dear All,

I am using perform statement in script.

the code for subroutine in separate program type (e).

But unable to get the output.

Following is my code of subroutine & form.

Regards,

Dilip

Script code

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &IT_MARA-MATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

Subroutine code

Form get_val tables in_tab structure itcsy

out_tab structure itcsy.

select * from makt into table it_makt

where matnr = in_tab-value.

data temp(40).

loop at it_makt.

temp = it_makt-maktx.

out_tab-name = 'maktx'.

out_tab-value = temp.

append out_tab.

endloop.

endform.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Dear Brad,

Thanks for u r prompt reply.

in_tab-name = it_mara-matnr

but in_tab-value is blank.

becoz of that it is not executing the query , is there any reason that in_tab-value is ''.

is there is wrong in calling of subroutine.

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &IT_MARA-MATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

Regards,

Dilip

14 REPLIES 14

Former Member
0 Kudos

Hi Diliip,

Try the following addition in your subroutine before your select statement:


  CLEAR: in_tab
  READ TABLE in_tab WITH KEY name = 'IT_MARA-MATNR'.
  IF not in_tab-value IS INITIAL.
     SELECT .....
  ENDIF.

Then when you are setting the text, handle it like this:


  CLEAR: out_tab.
  READ TABLE out_tab WITH KEY name = 'DESCR'.
  out_tab-value = it_makt-maktx.
  MODIFY out_tab index sy-tabix.

Also, you should pass the SAPscript language to the subroutine to make sure you select the correct language for the material description.

Cheers,

Brad

Former Member
0 Kudos

Dear Brad,

Thanks for u r prompt reply.

in_tab-name = it_mara-matnr

but in_tab-value is blank.

becoz of that it is not executing the query , is there any reason that in_tab-value is ''.

is there is wrong in calling of subroutine.

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &IT_MARA-MATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

Regards,

Dilip

0 Kudos

Hi Diliip,

In the program that calls your SAPscript, sometime before it calls the WRITE_FORM for the paragraph that contains the commands:

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &IT_MARA-MATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

there must be either a:

LOOP AT IT_MARA... or a READ TABLE IT_MARA...

Otherwise, IT_MARA-MATNR will be empty and thus the in_tab-value will be empty.

Make sure that the header line of the internal table IT_MARA is being filled in the original program, otherwise, it won't work!

Cheers,

Brad

Message was edited by: Brad Williams

0 Kudos

Dear Brad,

value in internal table in_tab-value is initial.

But in_tab-name = 'it_mara-matnr'.

REPORT ZGET_VAL .

tables makt.

data descr like makt-maktx.

data it_makt like makt occurs 0 with header line.

form get_val tables in_tab structure itcsy

out_tab structure itcsy.

*CLEAR: in_tab .

loop at in_tab.

READ TABLE in_tab WITH KEY name = 'IT_MARA-MATNR'.

IF not in_tab-value IS INITIAL.

*SELECT ..... ENDIF.

select * from makt into table it_makt

where matnr = in_tab-value.

endif.

endloop.

data temp(40).

loop at it_makt.

temp = it_makt-maktx.

out_tab-name = 'maktx'.

out_tab-value = temp.

append out_tab.

endloop.

0 Kudos

Hi Diliip,

The program I was referring to was the program that was calling the SAPSCRIPT.

The structure is like:

MAIN PROGRAM calls SAPSCRIPT

SAPSCRIPT calls ZGET_VAL.

When the MAIN PROGRAM calls the SAPSCRIPT it issues a WRITE_FORM function module call specifing the name of the paragraph to be printed. The data in IT_MARA must be populated from the MAIN PROGRAM (by use of LOOP AT, or READ TABLE) so that first it is available in the SAPSCRIPT, and thus available to ZGET_VAL when it is called from the SAPScript.

You can test whether the IT_MARA-MATNR has a value in the SAPScript by simply putting:

&'Material number is: 'IT_MARA-MATNR&

as a line in your SAPScript. If it comes out blank then you need to change the MAIN PROGRAM as I described in the last post.

If it has a value then we need to change the SAPScript.

Let me know how it goes.

Brad

0 Kudos

Dear Brad,

Yes the flow of program is correct as u said.

when the control goes to my second executable program where i have put my subroutine there in_tab-value is ''.

I tried with loop at my internal table but the o/p is not comming.

Regards,

Dilip

0 Kudos

Did you try:

&'Material number is: 'IT_MARA-MATNR&

In your SAPScript to confirm that the value is populated in the SAPScript?

It should print on the page like:

Material number is: 000000000000001001

If it prints like:

Material number is:

Then you need to look at your MAIN program.

Brad

0 Kudos

Dear Brad,

yes i need 2 change my main print program.

I check by debug the value in

in_tab-name = 'it_mara-matnr' but

in_tab-value = '' . is that is the reason the o/p is not comming?

Regards,

Dilip

0 Kudos

Diliip,

<b>PLEASE STOP LOOKING IN THE PROGRAM ZGET_VAL!!!</b>

Please answer the following question: In the MAIN PROGRAM and/or in the SAPSCRIPT does the field it_mara-matnr have a value?

In the MAIN program you can put a break point just before the call to the function module WRITE_FORM for the paragraph in question. In the SAPScript you can use the statement I provided in the last post.

Once you have answered this, we can then move on with solving this problem.

Brad

0 Kudos

Dear Brad,

Yes the value is there in my it_mara-matnr before i use :-

PERFORM write_data USING 'HEAD1' 'MAIN'.

Regards,

Dilip

0 Kudos

Thanks,

and if you put:

&'Material number is: 'IT_MARA-MATNR&

In your SAPscript?

Does it print out there?

Brad

0 Kudos

if i put 'material no is : - ' it prints

'material no is : - '098768888'.

Regards,

Dilip

0 Kudos

Hi Diliip,

So it looks like the header line of an internal table is not passed on PERFORM from a SAPScript.

Try something like:

/:DEFINE &ZMATNR& = &IT_MARA-MATNR&

/:PERFORM GET_VAL IN PROGRAM ZGET_VAL

/:USING &ZMATNR&

/:CHANGING &DESCR&

/:ENDPERFORM

And then in your program:


  CLEAR: in_tab
  READ TABLE in_tab WITH KEY name = 'ZMATNR'.
  IF not in_tab-value IS INITIAL.
     SELECT .....
  ENDIF.

That should help.

BTW - your program code needs looking at, but first lets get a value into in_tab-value.

Brad

0 Kudos

Dear Brad,

My problem is solved thanx for u r quick & correct response. I award u 10 pts.

Regards,

Dilip