cancel
Showing results for 
Search instead for 
Did you mean: 

Sapscript - email form - vendor address

Former Member
0 Kudos

Hello all,

we are emailing our purchase orders out of SAP to one of our email addresses, it is always the same address. As configuration, we have setup a new vendor X and use this vendor to enter the recipient email address.

We then enter this vendor number as partner into the output message in the purchase order. Partner type is VN for vendor, medium external send and we created a new output type. Once the output is triggered, email is sent to our email address.

The vendor address is also on the sapscript form:

/: ADDRESS PARAGRAPH AS

/: TITLE &LFA1-ANRED&

/: NAME &LFA1-NAME1&, &LFA1-NAME2&,

/: STREET &LFA1-STRAS&

/: POBOX &LFA1-PFACH& CODE &LFA1-PSTL

/: CITY &LFA1-ORT01&, &LFA1-ORT02&

/: POSTCODE &LFA1-PSTLZ&

/ :REGION &LFA1-REGIO&

Now the LFA1 table seems to contain the address of our vendor X that has been setup for email only. Meaning it prints the physical address of our email vendor on the form. But it should show the address of the actual vendor of the purchase order, which is in &EKKO-LIFNR&.

How can we show the correct address on the form?

Thanks

Anne

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

One way possibly would be to add:

/:DEFINE &WA_ADRNR& = ' '
/: PERFORM routinename IN PROGRAM program name
/: USING &EKKO-LIFNR&
/: CHANGING &WA_ADRNR&
/:ENDPERFORM

In your new routine, get the addressnumber value for EKKO-LIFNR from LFA1

Then

/:ADDRESS [DELIVERY - optional setting ] PARAGRAPH yourpara PRIORITY yourpriority LINES your lines
/: ADDRESSNUMBER &WA_ADRNR&
/:FROMCOUNTRY &T001-LAND1&  (or valid literal, like 'US')
/:ENDADDRESS

Former Member
0 Kudos

Hello,

thanks for your answer.

What is &WA_ADRNR& in that case?

Thanks

Anne

andrs_sarcevic
Contributor
0 Kudos

&WA_ADRNR& is the structure that will hold your wanted vendor address (or the address number), which will be obtained from the procedure 'routinename' pointed by Breakpoint.

Edited by: Andrés Sarcevic on May 5, 2010 1:36 AM

Former Member
0 Kudos

Hello again,

how and where would I define &WA_ADRNR& ?

In Breakpoints statement, it says: /:DEFINE &WA_ADRNR& = ' '

But I guess it is not supposed to be empty?

Thanks

Anne

andrs_sarcevic
Contributor
0 Kudos

Yes, it will be empty until it gets passed to the procedure.

You placed BreakPoint's code in whatever window you need to display the address:

/:DEFINE &WA_ADRNR& = ' '

/: PERFORM routinename IN PROGRAM program name

/: USING &EKKO-LIFNR&

/: CHANGING &WA_ADRNR&

/:ENDPERFORM

Next step is create a subroutine pool "PROGRAM NAME" with the routine "ROUTINENAME" to get the address number from the system.

And you print the address in the windows using again BreakPoint's code:

/:ADDRESS [DELIVERY - optional setting ] PARAGRAPH yourpara PRIORITY yourpriority LINES your lines

/: ADDRESSNUMBER &WA_ADRNR&

/:FROMCOUNTRY &T001-LAND1& (or valid literal, like 'US')

/:ENDADDRESS

Former Member
0 Kudos

Hi,

ok, I think I got it now. Please see below code. The sapscript and the subroutine pool are activated. I have set a break point into the subroutine pool, but whenever I start the output of the PO, it doesn't stop at the break point. So I guess it never reaches the subroutine.

Any suggestions why?

THANKS

Anne

 
:/ DEFINE &WA_ADRNR& = ' '
:/ PERFORM GET_ADDRESSNUMBER IN PROGRAM Z_PO_VENDOR_ADDRESS
:/ USING &EKKO-LIFNR&
:/ CHANGING &WA_ADRNR&
:/ ENDPERFORM


*&---------------------------------------------------------------------*
*& Subroutine pool   Z_PO_VENDOR_ADDRESS                               *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
PROGRAM  Z_PO_VENDOR_ADDRESS.

TABLES: LFA1.

*&---------------------------------------------------------------------*
*&      Form  GET_ADDRESSNUMBER
*&---------------------------------------------------------------------*
*       get the addressnumber value for EKKO-LIFNR from LFA1
*----------------------------------------------------------------------*
FORM GET_ADDRESSNUMBER TABLES fp_it_intab STRUCTURE itcsy
                              fp_it_outtab STRUCTURE itcsy.


  LOOP AT fp_it_intab.  <-- BREAKPOINT

    SELECT * FROM LFA1
         WHERE LIFNR = fp_it_intab-value.
    endselect.

    IF SY-SUBRC = 0.
      MOVE LFA1-ADRNR TO fp_it_outtab.
    ENDIF.

  ENDLOOP.


ENDFORM.                    "GET_ADDRESSNUMBER

Edited by: Anne on Aug 4, 2010 3:56 PM

Former Member
0 Kudos

Thanks to everyone, I finally got it to work.

Former Member
0 Kudos

Hi Anne,

Can u pls explain how u got the adrnr.? why the script control is not reaching the break point we set in sub routine?

Thanks,

Edited by: Dinesh15jan on Jan 21, 2011 11:51 AM

Answers (1)

Answers (1)

satyajit_mohapatra
Active Contributor
0 Kudos

You need to get ADRNR from LFA1 passing EKKO-LIFNR. To get the value you have to write a PERFORM-ENDPERFORM statement and use it in ADDRESS-ENDADDRESS command in sapscript as described by break point.

You need to create a subroutine pool and create the subroutine and the input and output format should be of structure ITCSY.

Check this link....

http://wiki.sdn.sap.com/wiki/display/profile/ExternalSubroutinesinSAPScript

Former Member
0 Kudos

Thanks,

so I'll have to copy the standard SAP program SAPFM06P for purchase orders and add the code.

But where exactly should I add the code?

Inlcude FM06PE02, form entry neu?

Thanks

Anne

satyajit_mohapatra
Active Contributor
0 Kudos

No.....copying the standard print program is not required. That's why we use subroutines in sapscript so that modifying the driver program can be avoided.

You have to create a new program, select type as subroutine pool in program attributes and create a subroutine there in the same format described in the link in my earlier post. The subroutine needs to be called in sapscript and the code has been already provided by break point.

You can make you changes copying the driver program as well, but again you have configure it in NACE. Also, it's not a good practice to modify standard print programs for small changes.

Former Member
0 Kudos

Thanks Satyajit. I have tried to create a subroutine in SE80 and it is asking me for an include. Should I select SAPFM06P (standard print program)? It then will add the Form into SAPFM06P. Is that correct?

Thanks

Anne

satyajit_mohapatra
Active Contributor
0 Kudos

Go to SE38-> Create A new Program->Set type as subroutine pool/Executable in attributes pop up.

Create a subroutine inside the new program. No need to modify standard print program.

Then SAPSCRIPT call the subroutine as

/: PERFORM <subroutine name> IN PROGRAM <New program created>

/: USING <parameter>

/: CHANGING <parameter>

/: ENDPERFORM