Application Development 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: 

Printing address using address number

Former Member
0 Kudos

I have the following code:

IF &PAGE& EQ 1

ADDRESSNUMBER &EKKO-ADRNR(K)&

FROMCOUNTRY &T001-LAND1&

ELSE

TITLE &LFA1-ANRED&

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

ENDIF

In this code ' If' statement is executed, i dont understand in if block , we are displaying only 'addressnumber' and 'from country', then how come entire address is printed in the sapscript.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Reshma,

Before code, First check table - ADRC

Here U find the link how with only address no., address prints in o/p.

If you want to work on few fields go for following code (Make changes according to your req.)


SELECT SINGLE adrnr INTO twlad-adrnr FROM twlad WHERE werks = lips-werks AND
                                                          lgort = lips-lgort.

    IF sy-subrc = 0.
      CALL FUNCTION 'ADDRESS_INTO_PRINTFORM'
        EXPORTING
          address_type            = '1'
          address_number          = twlad-adrnr
        IMPORTING
          address_printform_table = lt_address.

      CLEAR : tel_no,fax_no,email.
      SELECT SINGLE tel_number fax_number INTO (tel_no,fax_no) FROM adrc WHERE addrnumber = twlad-adrnr.

      SELECT SINGLE smtp_addr INTO email FROM adr6 WHERE addrnumber = twlad-adrnr.
    ENDIF.

Reply, if want other info regarding it.

7 REPLIES 7

Former Member
0 Kudos

hi,

I think this code in the script is under ADDRESS & ENDADDRESS statements. So, here the addressnumber is used to read the address from database and displayed in the output. Please check.

0 Kudos

Yes the actual code is as follows:

IF &EKKO-ADRNR(K)& EQ '          '                                    
ADDRESS PARAGRAPH AS                                                  
  TITLE    &LFA1-ANRED&                                               
  NAME     &LFA1-NAME1&, &LFA1-NAME2&, &LFA1-NAME3&, &LFA1-NAME4&     
IF &PAGE& EQ 1.                                                       
  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&                                            
ENDIF.                                                                
ENDADDRESS                                                            
ELSE                                                                  
ADDRESS PARAGRAPH AS                                                  
IF &PAGE& EQ 1                                                        
  ADDRESSNUMBER &EKKO-ADRNR(K)&                                       
  FROMCOUNTRY &T001-LAND1&                                            
ELSE                                                                  
  TITLE    &LFA1-ANRED&                                               
  NAME     &LFA1-NAME1&, &LFA1-NAME2&, &LFA1-NAME3&, &LFA1-NAME4&     
ENDIF                                                                 
ENDADDRESS

Now in the above code there is this 'if' block

IF &PAGE& EQ 1                                                        
  ADDRESSNUMBER &EKKO-ADRNR(K)&                                       
  FROMCOUNTRY &T001-LAND1&                                            
ELSE

So in this 'if' block , using the address number , entire address is displayed in Final output of the sap script. When I debug the sapscript, i m able to see only the addres number and not the address. My actual requirement is to display only some fields in the address and not the entire address, how can i do that???

Former Member
0 Kudos

Hi,

You have to put the code between ADDRESS & ENDADDRESS

Like this


/: IF &PAGE& EQ 1 
/: ADDRESS PARAGRAPH AS
/: ADDRESSNUMBER &EKKO-ADRNR(K)&
/: FROMCOUNTRY &T001-LAND1&
/: ENDADDRESS
/: ELSE
/: TITLE &LFA1-ANRED& 
/: NAME &LFA1-NAME1&, &LFA1-NAME2&, &LFA1-NAME3&, &LFA1-NAME4& 
/: ENDIF 

Regards

Dillip

Former Member
0 Kudos

Hi reshma,

If u take address number it displays the entire address.

if u want only some parts of the address then u should not use address number.

u can use title , street n other commands between address and end address.

0 Kudos

Can u plz give me a sample code

Former Member
0 Kudos

Hi Reshma,

Before code, First check table - ADRC

Here U find the link how with only address no., address prints in o/p.

If you want to work on few fields go for following code (Make changes according to your req.)


SELECT SINGLE adrnr INTO twlad-adrnr FROM twlad WHERE werks = lips-werks AND
                                                          lgort = lips-lgort.

    IF sy-subrc = 0.
      CALL FUNCTION 'ADDRESS_INTO_PRINTFORM'
        EXPORTING
          address_type            = '1'
          address_number          = twlad-adrnr
        IMPORTING
          address_printform_table = lt_address.

      CLEAR : tel_no,fax_no,email.
      SELECT SINGLE tel_number fax_number INTO (tel_no,fax_no) FROM adrc WHERE addrnumber = twlad-adrnr.

      SELECT SINGLE smtp_addr INTO email FROM adr6 WHERE addrnumber = twlad-adrnr.
    ENDIF.

Reply, if want other info regarding it.

Former Member
0 Kudos

STREET &LFA1-STRAS&

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

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

POSTCODE &LFA1-PSTLZ&

COUNTRY &LFA1-LAND1&

REGION &LFA1-REGIO&

U can use any of the above command.

if u want street n country then write as

Address

STREET &LFA1-STRAS&

COUNTRY &LFA1-LAND1&

End address