cancel
Showing results for 
Search instead for 
Did you mean: 

Printing Plant Address in Smartform

Former Member
0 Kudos

Hello everyone,

I have to print Plant address in smartform for my Invoice Document.

Plant will be taken from the sales order number.

I don't know much about the function module 'Read_Text'.

pls. explain about it. and how is it used for extracting the Plant's address.

Thanks

Regards

Tanu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

What i understood from ur query is enduser is maintaining plant address in header text of invoice.

If that is the case then only u need to use FM 'Read_text'.

First go to VF02/03 -> give invoice no.-> enter.

inside invoice -> goto -> header-> header text.

u will see all texts maintained at header level for that invoice.

If plant address is there then only you need to use read_text FM.

Steps for that -

goto 'STXH' table.-> display contents

give input in selection screen - > tdobject - 'VBBK' (for invoice header)

tdname - invoice no.

execute.

You will see no.of records for header text maintained for that invoice.

now pick up 'tdid' from that. (4 digit no.)

now goto se37 -> FM 'Read_Text' -> execute.

give input parameters -> client - > your client.

tdid -> id got from STXH table

language -> 'EN' or if any other then that one.

name - > invoice no.

object -> 'VBBK'.

after executing FM u will get entry in table 'LInes'.

double click on that and u will see actual text which was maintained in invoice header.

Ok now to display this text in smartform there are two ways-

1. just call FM 'Read_text' -> enter parameters as above and take output in one int table which is same

as table 'Lines'.

loop at int table -> field is tdline.

i.e. under one text element in smartform -

loop at int_tab.

write int_tab-tdline.

endloop.

But this is some what confusing so u can use following way -

2. in smartform create one text element .- > at top left there is one drop down -> select 'Include Text'.

Just pass parameters as above in that window.

dont forget to check the box -> 'No error if text does not exist'.

The text maintained under that id will come automatically in ur smartform.

Now if Plant address is not maintained in header text then just do this -

get plant no. from invoice, (VBRP - Werks)

get address no for that plant from T001W-adrnr.

get detailed address from ADRC table -> input this address no.

print it in smartform.

I think this will help to solve ur problem.

regards

Former Member
0 Kudos

Thanks Vishal. You've taken so much time and given a comprehensive solution.

Answers (4)

Answers (4)

Former Member
0 Kudos

refer this code.

pass ur plant intotvko and u will get adrnr.

pass this into adrc and get address.

SELECT adrnr from tvko into addrnum1

where vkorg = wa_vbak-vkorg.

ENDSELECT.

IF SY-SUBRC EQ 0.

SELECT * FROM ADRC INTO TABLE IT_ADRC1

WHERE ADDRNUMBER = ADDRNUM1.

READ TABLE IT_ADRC1 INTO WA_ADRC1 INDEX 1.

ABOUT READ_TEXT.

refer this and just pass ur entries.

if u dont know aboutentries then describe in detail which text u want to read.

MOVE WA_LIKP-VBELN TO TEXT_NAME1.

MOVE 'Z004' TO TEXT_ID1.

MOVE 'VBBK' TO TEXT_OBJECT1.

SELECT SINGLE TDOBJECT FROM STXH INTO TEXT_OBJECT1

WHERE TDOBJECT EQ TEXT_OBJECT1

AND TDID EQ TEXT_ID1

AND TDNAME EQ TEXT_NAME1.

if sy-subrc eq 0.

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = TEXT_ID1

LANGUAGE = SY-LANGU

NAME = TEXT_NAME1

OBJECT = TEXT_OBJECT1

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = itab_lt_tline1.

  • LOOP AT itab_lt_tline1 into wa_line1.

  • LR_NO = wa_line1-tdline(50).

  • ENDLOOP.

ENDIF.

no need to use read_text.

Edited by: MONIKA DHUMAL on Apr 3, 2009 10:40 AM

Former Member
0 Kudos

Hi,

Read_text sample code :

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = zvid

language = 'R'

name = zvname

object = 'VBBK'

IMPORTING

header = thead

TABLES

lines = line

EXCEPTIONS

OTHERS = 8.

DATA: zvname LIKE thead-tdname.

DATA: zvid LIKE thead-tdid.

DATA : line LIKE tline OCCURS 0 WITH HEADER LINE

I think Id , name and Object are you can get from STXH table. Output will be in LINE.

Former Member
0 Kudos

Hi,

Case 1. : Use read_text by providing the Plant address number as input to it. for that first get the Plant address number from T001w by providing Plant No as input to T001w using select query. The Output of Read_text will be storing in Tlines parameter. Then Place Tline-tdline in needed place to display the address.

Case 2 ; with out using read_text you can fetch it from ADRC Table by writing Select statements in order to provide Address number as input to ADRC. Place the ADRC Fields directly or concatenate the ADRC fields into one variable and place it in required position.

Former Member
0 Kudos

How can we get the function Read_text parameters values to pass ? from where can i get 'id' and 'object' to pass for my Adrnr?

Edited by: tanu007 on Apr 3, 2009 5:45 AM

Former Member
0 Kudos

why do u need read_text just fetch the addressnumber for the plant, then pass it to address node of smartform

Former Member
0 Kudos

Does that work if I pass Address No. from Plants table to the Adress Node in Smartform? I haven't worked with Address node yet in Sforms. I can check it out.

Former Member
0 Kudos

Get address number form T001w based on plant, then get address from ADRC based on this addrnumber.