cancel
Showing results for 
Search instead for 
Did you mean: 

get value from PO header text in SAPScript

former_member443015
Participant
0 Kudos

Hello all,

I am creating a PO form via transaction SE71.

In my PO form, I would like to add a logic to check if the PO header reference field have values or not.

To display the value, I have used the following script in the PO form:

INCLUDE &T166K-TXNAM& OBJECT &T166K-TDOBJECT& ID 'F02' LANGUAGE E PARAGRAPH Z1

where F02 is the field ID

Actually, Instead of displaying the value of the field, I would like to check whether the field have values or not?

Can I ask how is the script to perform this?

I have tried the follow:

IF INCLUDE &T166K-TXNAM& OBJECT &T166K-TDOBJECT& ID 'F02' LANGUAGE E PARAGRAPH Z1 NE SPACE

::::::::::::::::::

ENDIF

it failed.

Thanks

Sunny

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

INCLUDE is used to add the SO10 text in the output script, if you put IF condition on this it may not have desired result.

Here is what I suggest.

1) Structure T166K being a standard one, it must be getting populated by standard SAP driver program so you may not requore to do anything to populate it.

2) once it is populated, may be in MAIN window, you can call a subrotinue program to check if the text exists, of course you need to pass T166K values to subrotinue. In subrotinue give call to READ_TEXT and see if text exists and return a boolean value, which you can easily check in SAPScript program.

DO some debug and you should be good.

check sample [code|http://www.sapdev.co.uk/sapscript/sapscript_executeabap.htm] for the same.

former_member443015
Participant
0 Kudos

Before I call the read_text function, I am now going to test my subroutine program.

My subroutine program is

REPORT ZREADPOHDRTXT.

FORM READ_PO_HDRTXT TABLES INTTAB STRUCTURE ITCSY OUTTAB STRUCTURE ITCSY.

READ TABLE INTTAB INDEX 1.

OUTTAB-NAME = '1'.

OUTTAB-VALUE = '2'.

MODIFY OUTTAB INDEX 1.

ENDFORM.

In my SAP form, I have the following coding:

/: DEFINE &S1& = 'RRR'

/: DEFINE &S2& = 'QQQ'

/: PERFORM READ_PO_HDRTXT IN PROGRAM ZREADPOHDRTXT USING &S1& CHANGING &S2&

/: ENDPERFORM

  • &S2&

the final result of &S2& is 'QQQ', it seems the subroutine have not been called.

Do you have any ideas what I have doing wrong?

Thanks again

Former Member
0 Kudos

try this


REPORT ZREADPOHDRTXT.
FORM READ_PO_HDRTXT using S1 type char3 changing S2 type char3.
S2 = 'Changed"
ENDFORM.

In my SAP form, I have the following coding:

/: DEFINE &S1& = 'RRR'
/: DEFINE &S2& = 'QQQ'
/: PERFORM READ_PO_HDRTXT IN PROGRAM ZREADPOHDRTXT USING &S1& CHANGING &S2&
/: ENDPERFORM
* &S2&

Former Member
0 Kudos

oh well, that would be an "external perform".

but there is no need to trigger a routine from the form.

BEFORE the form is beeing processed the driver program runs and gets all the adata for the form. you can do your check with READ_TEXT in there.

use some implicit enhancement poiint at end of GET_DATA routine or whatever.

You got to enhance somewhenre between original data selection, at least ebeln & ebelp should be available, and the call of the text element.

Hint: variable defined globally in driver program are automatically available in form.

former_member443015
Participant
0 Kudos

Hello Shital,

I have followed the coding, still not work.

It seems that fail to call the form from external program.

The external program is a subroutine program, are there any setting before calling the subroutine program?

Thanks

former_member443015
Participant
0 Kudos

Hello Florian,

So many thanks of your suggestions.

For the driver program that you mentioned, is it the program defined under the below path?

SPRO->IMG-<Material Management->purchasing->messages->Forms (Layout Sets) for Messages->Assign Form and Output Program for Purchase Order

for this PO, the program is SAPFM06P, is it modify this program by adding the READ_TEXT to checking?

Thanks again.

Sunny

Clemenss
Active Contributor
0 Kudos

Hi Sun Yi,

if you use a standard print driver program, you sholu not modify it. Then the best way is to use external perform in the sapscript form.

Note that all parameters are passed in the structure ITCSY with componets NAME and VALUE. Take the USING parameters for NAME OBJECT ID LANGUAGE, do a PERFORM in Z_PROGRAM. In the Z program, use function READ_TEXT to check if there are text lines stored and then set the CHANGING parameter i.e. TEXT_EXISTS accordingly.

Please be aware that you may have leading zeros in the text name - they may not be passed to the subroutine because all values are treated as tect and leading zeros may be suppressed.

Do it according to the samle code given by SAP for [http://help.sap.com/erp2005_ehp_02/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm|http://help.sap.com/erp2005_ehp_02/helpdata/EN/d1/803279454211d189710000e8322d00/content.htm].

Regards,

Clemens

Answers (1)

Answers (1)

Former Member
0 Kudos

1. you need to fill structure t166p in your print program BEFORE calling the text element which has the include in it.

2. - in print program use FM READ_TEXT

- if you just need the info about existance of text to decide whether to print an empty line after it or not you can work a bit more elegant. After your INCLUDE statement do following:

/: IF &SAPSCRIPT-SUBRC& EQ ' 0'

/

/: ENDIF

former_member443015
Participant
0 Kudos

Hello,

Many thanks of your reply.

May I ask you a little bit detail about this?

1. Where can I define function module for PO? use transaction se37?

2. My PO was copy from original existing PO, usually, the retrieve data coding are defined in "Page Window" area or any other area?

I am new in designing PO form, sorry that my concept of the PO form may be not clear enough.

Thanks again

Sunny

Former Member
0 Kudos

Ok my answer lacks detail. On to a fresh start.

1. Sorry you misunderstood me there, you dont need to create a FM for your form or the PO. The function module READ_TEXT is a SAP standard one. What i really meant is that you enhance/modify the driver program, call READ_TEXT here to check whether the text exists and set a globally defined flag depending on existance of the text.

in for you can then do:

/: IF &FLAG& = 'X'

/: INCLUDE ....

/: ENDIF