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

condition for adding zero in a string

Former Member
0 Likes
1,375

Hi all,

iam having small doubt regarding writing if condition for adding leading zero in a string.my requirement was iam having a purchase org. field in the selection screen. so if user clicks on its F4 help it is taking the existing value in it which contains 0 123456 of 8 characters length. but if user enters pur.org manually it has to add zero by default to that value.

plz help me .

Regards,

Kumar.

8 REPLIES 8
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,157

Hi,

Assign the field to character type variable.

Unpack the variable and then assign it ot the field.

Eg.

variable = field.

unpack variable to variable.

field = variable.

Read only

Former Member
0 Likes
1,157

Hi,

Even if the user is using F4 or manually enters..

you can fill with leading zeroes..

DATA: V_CHAR(8) VALUE '1234567'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V_INPUT

IMPORTING

OUTPUT = V_INPUT.

WRITE: / V_INPUT.

Thanks,

Naren

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,157

Hi

Before using that value entered by use. Call FM

CONVERSION_EXIT_ALPHA_INPUT

for your purpose.

Regards,

kumar

Read only

Former Member
0 Likes
1,157

use fm

CONVERSION_EXIT_ALPHA_INPUT

regards

shiba dutta

Read only

Former Member
0 Likes
1,157

hi Kumar,

do this way

go to se11 -> give the table name -> double click on the data element -> double click on the domain -> in Output Characteristics tab double click on conversion Routine-> you will find a FM use it before the select statement ..

regards,

santosh

Read only

Former Member
0 Likes
1,157

Kumar ,

AT SELECTION OUTPUT.

p_org

use FM CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = p_org

IMPORTING

OUTPUT = o_org

EXCEPTIONS

OTHERS = 1.

(OR).

You know that it is having 8 chars.

data : v_len type i,

v_diff type i.

v_len = strlen (p_org).

v_diff = 8 - v_len.

if v_diff ne 0.

do v_diff times.

concatenate '0' p_org into p_org.

enddo.

endif.

Pls. mark if useful

Read only

0 Likes
1,157

and murali plz have a look at my code and solve this.

  • fill range table sel_proc_org for purchase organisation

IF is_criteria-purchase_org IS NOT INITIAL.

lt_search_proc_org-sign = 'I'. " inlcuding

find /sapsrm/if_pdo_aoms_c=>gc_org_type in is_criteria-purchase_org.

if sy-subrc = 0.

MOVE IS_CRITERIA-PURCHASE_ORG to LT_SEARCH_PROC_ORG-LOW.

else.

if is_criteria-purchase_org .(need code here).................................

CONCATENATE

/sapsrm/if_pdo_aoms_c=>gc_org_type " O like Type Organisation

is_criteria-purchase_org " Org.ID

INTO lt_search_proc_org-low

SEPARATED BY space.

endif.

endif.

FIND /sapsrm/if_pdo_aoms_c=>gc_asterix IN lt_search_proc_org-low.

IF sy-subrc = 0.

lt_search_proc_org-option = 'CP'. " generic search

ELSE.

lt_search_proc_org-option = 'EQ'. " only single value

ENDIF.

APPEND lt_search_proc_org TO et_search_proc_org.

ENDIF.

Read only

Former Member
0 Likes
1,157

Hi Kumar,

use FM <b>CONVERSION_EXIT_ALPHA_INPUT</b>

reward if useful.