Skip to Content

get value from PO header text in SAPScript

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 08, 2010 at 11:09 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 08, 2010 at 09:44 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Sheung Lai Sunny LI

      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