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

Select Single *

Former Member
0 Likes
2,357

Hello All,


Slect single * from t881 where rldnr = p_rldnr.
if t881-tab ne 'ZZXG1A'. (This can be ZZXG1T)
i need to change the 'T' to 'A'.
so ZZXG1AT becomes ZZXG1A.

rldnr = ledger

p_rldnr is the parameter used enters.

Regards,

- Sravan

20 REPLIES 20
Read only

Former Member
0 Likes
2,325

Hi sravan,

1. Simple.

2. use like this.

REPORT abc.

DATA : m(30) TYPE c.

m = 'ZZXG1A'.

<b>REPLACE 'A' IN m WITH 'T'.</b>

break-point.

regards,

amit m.

Read only

Former Member
0 Likes
2,325

Hi Sravan,

Can you please complete your question...

Slect single * from t881 where rldnr = p_rldnr.

if t881-tab ne 'ZZXG1A'. (This can be ZZXG1T)

t881-tab+5(1) = 'T'.

MODIFY t881 TRANSPORTING tab.

Read only

Former Member
0 Likes
2,325
REPORT  YCHATEST                                .

tables:t881.

parameters : p_rldnr like t881-rldnr.

Select single * from t881 where rldnr = p_rldnr.

if t881-tab ne 'ZZXG1A'.
replace 'T' with 'A' into t881-tab.
write : t881-tab.
endif.

Message was edited by: Sekhar

Read only

0 Likes
2,325

Hi All,

Thanks for your postings.

Replace works fine but, the Table always not turns to be ZZXG1T, it could be ZZXG1<b>X</b>.

That is the reason only the last character has to be modified to 'A'.

regards,

- Sravan

Read only

0 Likes
2,325

Hi,

Use...

Select single * from t881 where rldnr = p_rldnr.

if t881-tab ne 'ZZXG1A'.

<b>*This converts the last character from A to T</b>

t881-tab+5(1) = 'T'.

MODIFY t881 TRANSPORTING tab.

endif.

Read only

0 Likes
2,325
REPORT  YCHATEST                                .

tables:t881.

data : len type i,
       length type i.
parameters : p_rldnr like t881-rldnr.

Select single * from t881 where rldnr = p_rldnr.

len = strlen( t881-tab ).
length = len - 1.

if t881-tab ne 'ZZXG1A'.
replace t881-tab+length(len) with 'A' into t881-tab.
write : t881-tab.
endif.
Read only

0 Likes
2,325

Hi sravan

HI sravan

try like this

Select single * from t881 where rldnr = p_rldnr.

dat = t881-tab.

<b>dat1 = dat+5(1).</b>

replace dat1 in dat with 'A'

it is working for me correctly

<b>data: dat(10) type c, dat1 type c.

dat = 'ZZXG1A'.

dat1 = dat+5(1).

replace dat1 in dat with 'X'.

write dat.</b>

OR you can try this

replace dat1 with 'X' into dat.

if dat ne '....'

regards

kishore

Message was edited by: Harikishore Sreenivasulu

Message was edited by: Harikishore Sreenivasulu

Read only

0 Likes
2,325

Hi Harikishore,

I receive the message 'in Dat' is not expected.

Regards,

- Sravan

Read only

0 Likes
2,325

Hi Sravan,

Please check my previous post , it will replace last character with A irrespective of the length

Read only

0 Likes
2,325

Hi Sekar,

I implemented the code provided and i receive the message "Offset specification '+LENGTH' is not Numeric"

replace t881-tab+length(len) with 'A' into t881-tab.

Read only

0 Likes
2,325

Did you define length and len as Integer data types.

DATA length TYPE i.

DATA len TYPE i.

Read only

0 Likes
2,325

Hi,

Yes, i have done that.

Regards,

- Sravan

Read only

0 Likes
2,325

Hi Sravan,

I have even tested it. It works fine for me.

Can you please post your code...

DATA str(12) VALUE '12335'.
DATA len TYPE i VALUE 0.
DATA len1 TYPE i VALUE 1.
REPLACE str+len(len1) WITH 'A' INTO str.

Read only

0 Likes
2,325

Hi,


data: len type i,
      length type i.
*t881-tab is defined as Character type C of 10
SELECT single * from t881 where rldnr = p_rldnr.
* The output of the above could be ZZXG1T OR ZZEMEA1T
if t881-tab ne 'ZZXG1A'.
len = strlen( t881-tab ).
length = len - 1.
-->replace t881-tab+length(len) with 'A' into t881-tab.
endif.

The message occurs at the arrow pointed.

Regards,

- Sravan

Read only

0 Likes
2,325

Hi Sravan,

I hope you are using the table workarea.

Do this modification...


<b>TABLES: t881.
DATA wa LIKE t881.</b>data: len type i,
length type i.

SELECT single * from t881 <b>INTO wa</b> where rldnr = p_rldnr.
if wa-tab ne 'ZZXG1A'.
len = strlen( wa-tab ).
length = len - 1.
replace wa-tab+length(len) with 'A' into wa-tab.
endif.

Read only

Former Member
0 Likes
2,325
Slect single * from t881 where rldnr = p_rldnr.
if t881-tab not in 'ZZXG1A'.
t881-tab = 'ZZXG1T'.
endif.
Read only

hymavathi_oruganti
Active Contributor
0 Likes
2,325

u can use

1.REPLACE statement as well

or else

2.u can do like this no.

if t881-tab ne 'ZZXG1A'.

t881-tab = 'ZZXG1T'.

Read only

Former Member
0 Likes
2,325

HI sravan

Select single * from t881 where rldnr = p_rldnr.

dat = t881-tab.

replace 'A' in dat with 'T'.

if dat ne 'ZZXG1T'.

regards

kishore

Read only

Former Member
0 Likes
2,325

Hi,

Use:

Select single * from t881 where rldnr = p_rldnr.

if t881-tab ne 'ZZXG1A'.

t881-tab = 'ZZXG1AT'.

endif.

Lokesh

Read only

Former Member
0 Likes
2,325

Hi Sravan,

You can use either of the following:

a) TRANSLATE : This command will change your 'T' to 'A' if its ZZXG1T. If its not, it will leave it as it is.


SELECT SINGLE * FROM T881 WHERE RLDNR = P_RLDNR.
DATA: WA_CHANGE(2) VALUE 'TA'.
TRANSLATE T881-TAB USING WA_CHANGE.

b) RELPACE : This too will perform the same function.

REPLACE 'T' WITH 'A' INTO T881-TAB.

The only difference between the two is that TRANSALTE replaces all occurances of a character with the one succeeding it in WA_CHANGE, while REPLACE will replace only the 1st occurance of the character.

Hope this helps,

Regards,

Madhur

NB: Please do award points if found helpful.

Message was edited by: Madhur Chopra