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

issue regarding the zip code for US

Former Member
0 Likes
866

Hi team,

I have a problem while generating the file.

For nine digit zip code, insert a hyphen after the fifth digit. i.e.; 631464714 it should be like 63146-4714.

and this zip code should be valid if the country is US.

Guys please help me, how to code this.

Thanks & Regards,

Dheeraj.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
735

data : v_zip_us(10).

if wa_tab-country = 'US'.

  concatenate wa_zipcode+0(5) '-' wa_zipcode+5(4) into v_zip_us.

else.

  v_zip_us = wa_zipcode.

endif.

wa_tab-zipcode = v_zip_us.

2 REPLIES 2
Read only

Former Member
0 Likes
736

data : v_zip_us(10).

if wa_tab-country = 'US'.

  concatenate wa_zipcode+0(5) '-' wa_zipcode+5(4) into v_zip_us.

else.

  v_zip_us = wa_zipcode.

endif.

wa_tab-zipcode = v_zip_us.

Read only

Former Member
0 Likes
735

Hi Dheeraj,

You can use STRLEN method & CONCATENATE to achive this.

For example say postal code is in l_postalcode.

Then l_length = STRLEN (l_postalcode).

IF l_length>5.

l_length = l_length-5.

CONCATENATE l_postalcode+0(5) '-' l_postalcode+5(l_length) INTO l_postal_final.

CONDENSE l_postal_final NO-GAPS.

ENDIF.

Regards,

Shiva.