Application Development and Automation 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: 
Read only

Sap script Change program

Former Member
0 Likes
1,758

Hi all,

I m trying to modify the standard program of Purchase order sapfm06p. I copied the program from se38 and also function group from se80 into ypomedruck. I also duplicated include LMEDRUCKF0C and wrote the following code.

FORM read_address USING p_parvw LIKE nast-parvw

p_parnr LIKE nast-parnr

CHANGING s_ekko LIKE ekko.

  • Lesen Lieferantendaten ----------------------------------------------*

  • die Adressnummer wird immer in ekko-adrnr übernommen, falls ekko-adrnr

  • nicht gefüllt ist werden die lfa1-Felder ausgegeben

IF s_ekko-lifnr NE space.

CLEAR ekpa.

IF p_parnr NE space AND p_parnr NE s_ekko-lifnr.

CLEAR: s_ekko-verkf, s_ekko-ihrez.

ekpa-lifn2 = p_parnr.

SELECT SINGLE * FROM lfa1 WHERE lifnr = ekpa-lifn2.

SELECT SINGLE verkf FROM lfm1 INTO (s_ekko-verkf)

WHERE lifnr = ekpa-lifn2

AND ekorg = s_ekko-ekorg.

s_ekko-adrnr = lfa1-adrnr.

ELSE.

CALL FUNCTION 'MM_ADDRESS_GET'

EXPORTING

i_ekko = s_ekko

IMPORTING

e_sadr = sadr

EXCEPTIONS

OTHERS = 1.

sadr-name1 = 'Vijay group of Industries Pvt Ltd.'.

modify sadr.

MOVE-CORRESPONDING sadr TO lfa1.

update lfa1.

IF s_ekko-adrnr IS INITIAL.

s_ekko-adrnr = lfa1-adrnr.

ENDIF.

ENDIF.

ENDIF.

  • Lesen Lieferwerk ----------------------------------------------------*

IF s_ekko-reswk NE space.

SELECT SINGLE * FROM t001w WHERE werks EQ s_ekko-reswk.

IF t001w-adrnr IS INITIAL.

MOVE-CORRESPONDING t001w TO lfa1.

ELSE.

CLEAR addr1_sel.

addr1_sel-addrnumber = t001w-adrnr.

CALL FUNCTION 'ADDR_GET'

EXPORTING

address_selection = addr1_sel

IMPORTING

sadr = sadr

EXCEPTIONS

OTHERS = 1.

IF sy-subrc EQ 0.

sadr-name1 = 'Vijay group of Industries Pvt Ltd.'.

modify sadr.

MOVE-CORRESPONDING sadr TO lfa1.

ELSE.

MOVE-CORRESPONDING t001w TO lfa1.

ENDIF.

s_ekko-adrnr = t001w-adrnr.

ENDIF.

CLEAR t001w.

ENDIF.

break-point.

lfa1-name1 = 'Vijay Inc'.

modify lfa1.

break-point.

ENDFORM. " READ_ADDRESS

What I am trying to do here exactly is getting address from standard tables and changing that in the program Also I wanted the new address to be displayed in the print preview. But I couldn't understand where it is going wrong. Please go through the code and inform me the error. I couldn't understand how the inofrmation is retrieved from standard tables and through which variables it is send to the form layout set. If you can please explain this concept also.

Regards,

Varun.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,679

u need to do modifications in the sapscript MEDRUCK( by copying it into zform)..this is the FORM for PO print.. chk the address box in this form n change the address variables accordingly..

Hope it helps,

Regards,

BIkash

15 REPLIES 15
Read only

Former Member
0 Likes
1,680

u need to do modifications in the sapscript MEDRUCK( by copying it into zform)..this is the FORM for PO print.. chk the address box in this form n change the address variables accordingly..

Hope it helps,

Regards,

BIkash

Read only

0 Likes
1,679

Hi Agarwal,

I did that I copied medruck ino ypomedruck. But still it is the same problem.

Regards,

Varun.

Read only

0 Likes
1,679

HI Varun,

Why dont you move these values into a internal table & then use those tables for the values.I guess we cannot change the SAP tables data.Even if you try to change ,it retains the original picked data as we are not commiting the job.

Read only

0 Likes
1,679

Hi Phani,

I did not understand how the data is transfered from print program to the script. If you go through the code in the editor of address window he has written as &lfa1-name1&. What is he referring actually ? Is he referring the standard tables or internal tables in the program. I think he is using standard table because when I debug I did not come across internal table with name lfa1. Moreover I dont have a clear picture of how data is transfered from print program to the script.

Regards,

Varun.

Read only

0 Likes
1,679

LFA1 is the structure which has the vendor information.The code selects this information in the same strcuture name LFA1 & passes to the sapscript. The best way to chk this is see the Text Element under which ur data is written in ur sapscript. Then goto ur program, search where that Text element is being called(write_form) put a breakpoint at that function module n run ur transaction...at this stage c the values of the variables (LFA1 structure in ur case)..u ll c how they r gettin transferred.

Hope it helps.

regards,

Bikash

Read only

0 Likes
1,679

Hi Varun,

He is using the Header of the standard table.

He does select * from lfa1 where kunnr = xxx.

So even when you use update or modify it doesnt matter,as its only the header which is used.so the data wont change.If you want your data to be printed,then you have to move it to an internal table & also change in the layout to write that information.

Read only

0 Likes
1,679

Hi all,

I declared a variable called zname1 of type lfa1-name1 and assignned the value to it and then I changed the code in the editor window of address of form ypomedruck in the following manner :

IF &PAGE& EQ 1.

INCLUDE &T024E-TXADR& OBJECT TEXT

ENDIF.

IF &EKKO-ADRNR(K)& EQ ' '

ADDRESS PARAGRAPH AS

NAME &ZNAME1&, &LFA1-NAME2&,

STREET &LFA1-STRAS&

POBOX &LFA1-PFACH& CODE &LFA

CITY &LFA1-ORT01&, &LFA1-ORT

POSTCODE &LFA1-PSTLZ&

COUNTRY &LFA1-LAND1&

REGION &LFA1-REGIO&

FROMCOUNTRY &T001-LAND1&

ENDADDRESS

ELSE

ADDRESS PARAGRAPH AS

TITLE &ZNAME1&

ADDRESSNUMBER &EKKO-ADRNR(K)&

FROMCOUNTRY &T001-LAND1&

ENDADDRESS

ENDIF

Still the value of zname1 is not displayed in the print review. I dont see any reason as why this is not working . Can anyone please explain me.

Regards,

Varun.

Read only

0 Likes
1,679

Hi Varun,

I think the 2nd part is getting triggered.Put a break-point & check.ie

ADDRESS PARAGRAPH AS

<b>TITLE &ZNAME1&</b>

ADDRESSNUMBER &EKKO-ADRNR(K)&

FROMCOUNTRY &T001-LAND1&

ENDADDRESS

& title is not the field zname1.thats why i think you are getting space.

Read only

0 Likes
1,679

Hi Phani ,

This still doesn't work for me. What do these signify in the address command :

<b>Title,Street etc.,</b>

Even I used Break-point in the ediotr of window but it doesn't work.

Regards,

Varun.

Read only

0 Likes
1,679

Hi Varun,

Break point wont work in editor.You need to activate the debugger in the SE71 & then debug the script.

Read only

0 Likes
1,679

Hi Phani,

If i specify the value in the editor as &ZNMAE1& this is getting printed in print review but when I specify it as title &ZNAME1& in the address command it disapppears. I am not able to understand how address command works even if I go through the documentation. Can you please explain me how it works and what should be the reason for not getting printed.

Regards,

Varun.

Read only

0 Likes
1,679

Hi Varun,

The ADDRESS-ENDADDRESS command formats addresses according to the postal norms of the recipient's country, as defined in the country parameter.

So if the parameterdoesnt match then you will not get any thing.declare the zname as lfa1-anred & yoou will get the data.

Read only

0 Likes
1,679

Hi Phani,

Even though I modified the code as this way in the editor of window still I am not able to display the value of zname1 in my program. I declared it as zname1 type lfa1-anred. If I dont include in paragraph it is displayed.

IF &PAGE& EQ 1.

INCLUDE &T024E-TXADR& OBJECT TEXT ID ADRS LANGUAGE &EKKO-SPRAS&

ENDIF. IF &EKKO-ADRNR(K)& EQ ' '

ADDRESS TITLE &ZNAME1&

NAME &LFA1-NAME2&, &LFA1-NAME3&, &LFA1-NAME4&

STREET &LFA1-STRAS&

POBOX &LFA1-PFACH& CODE &LFA1-PSTL2&

CITY &LFA1-ORT01&, &LFA1-ORT02&

POSTCODE &LFA1-PSTLZ&

COUNTRY &LFA1-LAND1&

REGION &LFA1-REGIO&

FROMCOUNTRY &T001-LAND1&

ENDADDRESS

ELSE ADDRESS

TITLE &ZNAME1&

ADDRESSNUMBER &EKKO-ADRNR(K)&

Regards,

Varun.

Read only

0 Likes
1,679

Hi Varun,

I am not too sure,but i think we should not specify the variables in the ADDRESS & END-ADDRESS.Remove them & see if you are able to get the value.

Read only

0 Likes
1,678

Hi Phani,

I am able to get the values out of ADDRESS - ENDADDRESS.

But they do not work in address command.

Regards,

Varun.