on 04-27-2010 4:05 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.