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

Reg : Logic

Former Member
0 Likes
849

Hi Experts ,

Im having some doubt in logic ??

Example : Im having lot of materials in which some materials are started with AD123456 ..

When iam exexuting a Sapscript on the form it is displyaing the Material no as AD123456

mY qUESTIOM IS when i execute the form the material numbers that are started with AD123456

Should display as AD-123456

iT HAS TO iNCLUDE THE '-' HYPHEN bETWEEN THE AD & 123456...

Not Only for this material this logiC belongs to all the materials that are started with AD & nOT FOR OTHERS

Regs,

Murthy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
806

Hi,

lat the field is F which is containing the value AD123456 . Now i want it

as AD -123456 .

Code :-

DATA : F1 type C .

concatenate F0(2) ' - ' F2(6) into F1.

WRITE : F1.

Output : AD -123456

Reward points if helpful.

Regards.

Srikanta Gope

Hi,

lat the field is F which is containing the value AD123456 . Now i want it

as AD -123456 .

Code :-

DATA : F1 type C .

concatenate F0(2) ' - ' F2(6) into F1.

WRITE : F1.

Output : AD -123456

Reward points if helpful.

Regards.

Srikanta Gope

6 REPLIES 6
Read only

Former Member
0 Likes
806

Hi,

suppose material is AD123456 and if AD is fix that means 2 positions are fixed then in drver program

str = AD123456

i = strlen ( str )

concatenate str0(2) '-' str2(i) into str1.

And modify script , if it is standard then copy and assign through NACE.

And at printing time instead of str print STR1.

Reward if useful!

Read only

Former Member
0 Likes
806

Hi Murthy,

you may use this in your form definition


/: IF &MATNR+0(2)& = 'AD'
   &MATNR+0(2)&-&MATNR+2&
/: ELSE
   &MATNR&
/: ENDIF

I hope it helps. Best regards,

Alvaro

Read only

Former Member
0 Likes
806

Hello,

Assume your material is in wrk_matnr.

<b>Reward all usefull answers. </b>

Cheers,

Rakesh.


data: wrk_len type i.
data: wrk_result1(2) type c.
data: wrk_result 2(8) type c.
data: wrk_result type mara- matnr
if wrk_matnr+0(2) EQ 'AD'.
wrk_len      = strlen ( wrk_matnr ).
wrk_result1 = wrk_matnr+0(2).
wrk_result2 = wrk_matnr+2(wrk_len).

concatenate wrk_result1 '-' wrk_result2 into wrk_result.

endif.

<b></b>

Read only

former_member189059
Active Contributor
0 Likes
806
if str(2) = 'AD'.
concatenate str(2) '-' str+2 into str.
endif.

^^^

Note that u <b>can</b> concatenate into the same variable as the original directly

Read only

Former Member
0 Likes
807

Hi,

lat the field is F which is containing the value AD123456 . Now i want it

as AD -123456 .

Code :-

DATA : F1 type C .

concatenate F0(2) ' - ' F2(6) into F1.

WRITE : F1.

Output : AD -123456

Reward points if helpful.

Regards.

Srikanta Gope

Read only

Former Member
0 Likes
806

REPORT ZTRIPS_TEST .

data:

w_matnr like mara-matnr value 'AD123456'.

write w_matnr.

replace first occurrence of 'AD' in w_matnr WITH 'AD-'.

write:/ w_matnr.