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: 

Getting table data from subroutine to SAPScript

Former Member
0 Kudos

Hello Experts,

I have a requirement which asks to display 3 new fields on the MEDRUCK form.

> Copied the MEDRUCK form to ZMEDRUCK.

> To display the whole table data, I selected the rows from the table and using 'SAVE_TEXT' function module I am writing all the records to standard text.

After writing in the standard text, using INCLUDE statement I am displaying in the form.

Here, I had an issue in displaying the data.

When I execute the ME4N transaction, I could see list of contracts in which I select one and print preview, the data displays fine for the first time.

Then when I go back and select another contract from the list of contracts and print preview, I could see the same data which is displayed for first contract is being displayed for this contract too.

Is there a way to clear the standard text after printing on the form?

Any inputs are highly appreciated.

Thanks!

Sandy

11 REPLIES 11

FredericGirod
Active Contributor
0 Kudos

Hi again Sandy,

are you sure your program didn't select the first contract and the second contract ?  (maybe you have several pages)


Fred

0 Kudos

Hi Fred,

Thanks for your response!

I think I confused you with my explanation. Let me make it clear.

> When executed ME4N transaction, I could see some 10 contracts (say for eg: 100,200,300,400,500,...,1000)displayed.

> I select one (for eg: 100) and print preview it. As this is the first time the data is displaying fine.

> But when I come back and select another contract (say 200) , I am again seeing the same data which is displayed for 100 contract.

> But when I completely come out and start executing ME4N transaction again, I could see the data fine whichever contract is print previewed for the first time.

So, is there any way to clear out the standard text after displaying it in SAPScript text elements.

Thanks!

Sandy

0 Kudos

I will try to debug if I have to manage this.

/h

call stack

and see why it takes the first contract

regards

Fred

0 Kudos

Yes Fred. I have checked in debug. Forgot to mention this point.

When I put the Sapscript and subroutine program in debug, the select query is returning the data needed for that contract but after perform statement in SAPscript, when the below executed,

INCLUDE ZMM_DRAD_DATA OBJECT TEXT ID ST LANGUAGE &EKPO-SPRAS&

The data retrieved is not the one we got from select query but the previous contract data is shown.

Did I miss anything here?

Thanks!

Sandy

Former Member
0 Kudos

Hai Sandeep,

1) You can use READ_TEXT to get the Standard Text in Script.

2) Kindly check whether the OBJECT ID varies as per the Selection before passing into the function module .

Please try this READ_TEXT FM and check , please update if any issues.

Thanks,

S.Rajendranath Raparthi.

0 Kudos

Hi,

Thanks for your response!

I am learning scripts now and pardon me for basic things.

From your statement, I understand that after saving the data retrieved from database using select query we can read the text using READ_TEXT. But after saving in the standard text, I am displaying it using INCLUDE Z_TXT OBJECT TEXT ID ST LANGUAGE &EKPO-SPRAS&

The data in Z_TXT is saved by calling SAVE_TEXT FM in the subroutine pool program.

I am not sure how to use READ_TEXT. Could you please let me know?

Thanks!

Sandy

raymond_giuseppi
Active Contributor
0 Kudos

Some buffering should happen, if you actually use the same standard text for every contract, also if you don't use some COMMIT WORK / COMMIT_TEXT results can be ... interesting. Did you check return code of SAVE_TEXT in subsequent executions ?

So either

Identify a FM to refresh buffer, look at FM like DELETE_TEXT_FROM_CATALOG , GET_TEXT_MEMORY and FREE_TEXT_MEMORY. (NB: What will happen when two or more users  print simultaneously ?)

or

Use another solution than this creation of a temporary text. (e.g. returning an internal table of text to Sap Script ?)

Regards,

Raymond

0 Kudos

Hi Raymond,

Thanks for your response.

I could find only one possibility of displaying internal table data on to the script. That is by storing the data in some standard text and display them on the form. I could not find any other method.

If it is selecting a single record then 'modify' statement does it all but our query returns more than one record and we need to display all of them.

So, after calling the SAVE_TEXT function module do you want to execute DELETE_TEXT_FROM_CATALOG? Could you please describe it more as I am new to these concepts?

Thanks again!

Sandy

Former Member
0 Kudos

Hello All,

Any inputs on the above scenario?

When I see in SO10, the data in the standard text is selecting fine but while printing on the form, I am getting the previous or first contracts details.

Any idea on how to clear the standard text?

Thanks for your help!

Venkat

0 Kudos

Hai Sandeep ,

                     Have you used READ_TEXT Function module ?

Thanks,

S.Rajendranath Raparthi.

0 Kudos

Thanks for your response.

I resolved the issue by dynamically creating separate standard texts for each contract and deleting the text using DELETE_TEXT.

So we select from STXH table and use DELETE_TEXT FM.

Sandy.