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

string operation

Former Member
0 Likes
1,392

hi all,

i need some help with string operation..

i am using a select-option which requires a user to enter the operation text .

SELECT-OPTION : S_LTXA1 FOR AFVC-LTXA1.

the requirement is that if the user enters a part of the string, i need to search that word and display the entire string that contains that paricular word or pattern..

eg: if the user entered "ASSEMBLE", i need to look up into AFVC-LTXA1 and pick up "ASSEMBLE TOP".

i have written the following piece of code but cant figure out where i went wrong because my internal table int_afvc soes not get populated,

FORM F_GET_TEXT.

*RANGES: R_LTXA1 FOR AFVC-LTXA1. "commented

**LOOP AT S_LTXA1. "commented

    • R_LTXA1-SIGN = 'I'. "commented

    • R_LTXA1-OPTION = 'CP'. "commented

    • CONCATENATE '%'S_LTXA1-LOW'%' into S_LTXA1-LOW. "commented

    • CONDENSE R_LTXA1-LOW. "commented

    • APPEND R_LTXA1. "commented

**ENDLOOP. "commented

LOOP AT INT_REPORT.

IF INT_REPORT-DEL12 <> ' '.

SELECT SINGLE AUFNR PLNBEZ AUFPL

INTO INT_AFKO

FROM AFKO

WHERE AUFNR = INT_REPORT-DEL12

AND PLNBEZ = INT_REPORT-MATNR.

APPEND INT_AFKO.

ENDIF.

ENDLOOP.

LOOP AT INT_AFKO.

SELECT SINGLE AUFPL APLZL ARBID LTXA1 OBJNR

INTO INT_AFVC

FROM AFVC

  • for all entries in int_afko "commented

WHERE AUFPL = INT_AFKO-AUFPL

AND LTXA1 LIKE '%S_LTXA1-LOW%'.

APPEND INT_AFVC.

ENDLOOP.

ENDFORM.

I have even tried with upper and lower case and by hardcoding values in place of S)LTXA1-LOW........

please suggest if i am going wrong somewhere..

Thanks,

Ruchi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,351

Well, upper and lower case will be an issue. I think you'll have to use native SQL.

Rob

12 REPLIES 12
Read only

Former Member
0 Likes
1,351

Hi Ruchi

do this way



PARAMETERS srch_str(20) TYPE c. 
CONCATENATE '%' srch_str '%' INTO srch_str. 
DATA text_tab TYPE TABLE OF doktl. 
SELECT * 
       FROM doktl 
       INTO TABLE text_tab 
       WHERE doktext LIKE srch_str. 

Regards Rk

Read only

vyende
Active Participant
0 Likes
1,351

I think this --> AND LTXA1 LIKE '%S_LTXA1-LOW%'

should be AND LTXA1 LIKE S_LTXA1-LOW

Read only

Former Member
0 Likes
1,352

Well, upper and lower case will be an issue. I think you'll have to use native SQL.

Rob

Read only

0 Likes
1,351

Like this:


s_ltxa1-low = '%ASSEMBLE%'.

EXEC SQL.
  SELECT afvc.aufpl, afvc.aplzl, afvc.arbid, afvc.ltxa1, afvc.objnr
  INTO :int_afvc
  FROM  AFVC
  WHERE UPPER(ltxa1)  like :s_ltxa1-low
ENDEXEC.

Rob

Read only

0 Likes
1,351

thanks Rob,

i figured out the problem .

when we use like in where clause of select, we can include only one where condition. giving multiple where conditions will cause it to fail.

however, right now it will select only those strings which exactly match my pattern...in other words upper case and lower case are still an issue ....

if you look at table AFVC ( for eg: AUFPL = 5041 )

You will find some text appears like : Assemble

: final

so there is problem of upper case and lower case, at times i miss out on the required strings due to this.

i will try out the piece of code that you have sent and see if that solves the CASE SENSITIVITY problem.

-Ruchi

Read only

0 Likes
1,351

You can use multiple LIKEs, but only one value will be returned.

Rob

Read only

0 Likes
1,351

Rob,

i get a run time error when i run the SQL . it says error 919 occured when running exeq sql......

wat do i do. its urgent

Read only

0 Likes
1,351

Any further information other than just 919?

Are you on an Oracle database? DB2??

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
1,351

still working on this

Read only

former_member219399
Active Participant
0 Likes
1,351

try this coding.

tables ZVMCCTEST.

select-options so_test for zvmcctest-Field1.

select * from ZVMCCTEST where field1 in so_test.

write zvmcctest-field1.

endselect.

also concatenate * before and after the string.

with regards,

Vamsi

Message was edited by:

Vamsi MM

Read only

Former Member
0 Likes
1,351

Hi Ruchi,

Follow one of the following methods:

Method 1:

Parameters: p_ltxa1 like afvc-ltxa1 lower-case.

data: v_ltxa1(42).

concatenate '%' p_ltxa1 '%' into v_ltxa1.

SELECT SINGLE AUFPL APLZL ARBID LTXA1 OBJNR
INTO INT_AFVC
FROM AFVC
WHERE AUFPL = INT_AFKO-AUFPL
AND LTXA1 LIKE v_ltxa1.

Method2)

SELECT-OPTION : S_LTXA1 FOR AFVC-LTXA1 lower-case.

RANGES: R_LTXA1 FOR AFVC-LTXA1. 

LOOP AT S_LTXA1.
 R_LTXA1-SIGN = 'I'.
 R_LTXA1-OPTION = 'CP'.
 CONCATENATE '*' S_LTXA1-LOW '*' into R_LTXA1-LOW. 
 CONDENSE R_LTXA1-LOW. 
 APPEND R_LTXA1.
ENDLOOP. 

SELECT SINGLE AUFPL APLZL ARBID LTXA1 OBJNR
INTO INT_AFVC
FROM AFVC
WHERE AUFPL = INT_AFKO-AUFPL
AND LTXA1 in r_ltxa1.

Regards,

Ravi

Read only

Former Member
0 Likes
1,351

hi ,

According to your requirement i understand this way, look at the code if it fits ur requirement.

tables : afvc.

data : begin of itab occurs 0.

include structure afvc.

data end of itab.

data : q_tab like itab occurs 0 with header line.

parameters : p_ltxa1 like afvc-ltxa1.

select * from afvc into table itab.

loop at itab.

if itab-ltxa1 cs p_ltxa1.

move itab-ltxa1 to q_tab-ltxa1.

append q_tab.

endif.

endloop.

loop at q_tab.

write : / q_tab-ltxa1.

endloop.

regards

sarath