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

Conversion problems between char data types

Former Member
0 Likes
810

Hello, I am searching a row in the table LTBP. But I don't understand Why I can't find any row.

I think that is because I am using different data elements.

the data element LTBP-WEMPF is char(12) and LFA1-LIFNR is char(10).

How I convert LFA1-LIFNR to LTBP-WEMPF?

Thanks,

the example code is this:


REPORT  YCO00_WMREQSAL.

TABLES: LFA1.

TYPES:
BEGIN OF NECESIDADES,
 TBNUM LIKE LTBP-TBNUM,
 BWART LIKE LTBK-BWART,
 BDATU LIKE LTBK-BDATU,
 WERKS LIKE LTBP-WERKS,
 LGNUM LIKE LTBK-LGNUM,
 MATNR LIKE LTBP-MATNR,
 MAKTX LIKE MAKT-MAKTX,
 TAMEN LIKE LTBP-TAMEN,
 MEINS LIKE LTBP-MEINS,
 MENGE LIKE LTBP-MENGE,
 ELIKZ LIKE LTBP-ELIKZ,
 WEMPF LIKE LTBP-WEMPF,
 NAME1 LIKE LFA1-NAME1,
END OF NECESIDADES.

DATA:
ti_necesidades TYPE NECESIDADES occurs 0 WITH HEADER LINE.

SELECT-OPTIONS: p_LFA1 FOR LFA1-LIFNR OBLIGATORY.

SELECT *
INTO CORRESPONDING FIELDS OF TABLE ti_necesidades
FROM LTBP
WHERE WEMPF = p_LFA1-low.

loop at ti_necesidades.
  write: / ti_necesidades-TBNUM,
           ti_necesidades-WERKS,
           ti_necesidades-WEMPF.
endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
749

Hi Jose,

The problem is WEMPF is case sensitive. If the data is available and if you try to search the data with different case, then you will not get any output.

U need the values in WEMPF as they are stored in the database table otherwise u will not get the result.

I have modified the report slightly and checked it. It works fine if while debugging the report i change the value as it is stored it table LTBP, then it gives proper output.

&----


*& Report ZTESTPG *

*& *

&----


*& *

*& *

&----


REPORT ztestpg .

TABLES: lfa1.

<b>DATA wempf_temp LIKE ltbp-wempf.</b>

TYPES:

BEGIN OF necesidades,

tbnum LIKE ltbp-tbnum,

bwart LIKE ltbk-bwart,

bdatu LIKE ltbk-bdatu,

werks LIKE ltbp-werks,

lgnum LIKE ltbk-lgnum,

matnr LIKE ltbp-matnr,

maktx LIKE makt-maktx,

tamen LIKE ltbp-tamen,

meins LIKE ltbp-meins,

menge LIKE ltbp-menge,

elikz LIKE ltbp-elikz,

wempf LIKE ltbp-wempf,

name1 LIKE lfa1-name1,

END OF necesidades.

DATA:

ti_necesidades TYPE necesidades OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS: p_lfa1 FOR lfa1-lifnr OBLIGATORY.

<b>wempf_temp = p_lfa1-low.</b>

**While debugging here I have changed the value and got the output. Whatever value we are entering in select-options, it is convetred into Upper case. hence I tried with this and came to know abt the problem.

SELECT *

INTO CORRESPONDING FIELDS OF TABLE ti_necesidades

FROM ltbp

WHERE wempf = wempf_temp.

LOOP AT ti_necesidades.

WRITE: / ti_necesidades-tbnum,

ti_necesidades-werks,

ti_necesidades-wempf.

ENDLOOP.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

6 REPLIES 6
Read only

Former Member
0 Likes
749

Hi,

If the vendor is with leading zeros..

call the function module CONVERSION_EXIT_ALPHA_INPUT to add leading zeros..Before doing the select.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = p_LFA1-LOW

IMPORTING

OUTPUT = p_LFA1-LOW.

Thanks,

Naren

Read only

dani_mn
Active Contributor
0 Likes
749

HI,

change with the field you are looking for comparision in this way both have same data type and length.

<b>SELECT-OPTIONS: p_LFA1 FOR LTBP-WEMPF OBLIGATORY.</b>

Regards,

Read only

Former Member
0 Likes
750

Hi Jose,

The problem is WEMPF is case sensitive. If the data is available and if you try to search the data with different case, then you will not get any output.

U need the values in WEMPF as they are stored in the database table otherwise u will not get the result.

I have modified the report slightly and checked it. It works fine if while debugging the report i change the value as it is stored it table LTBP, then it gives proper output.

&----


*& Report ZTESTPG *

*& *

&----


*& *

*& *

&----


REPORT ztestpg .

TABLES: lfa1.

<b>DATA wempf_temp LIKE ltbp-wempf.</b>

TYPES:

BEGIN OF necesidades,

tbnum LIKE ltbp-tbnum,

bwart LIKE ltbk-bwart,

bdatu LIKE ltbk-bdatu,

werks LIKE ltbp-werks,

lgnum LIKE ltbk-lgnum,

matnr LIKE ltbp-matnr,

maktx LIKE makt-maktx,

tamen LIKE ltbp-tamen,

meins LIKE ltbp-meins,

menge LIKE ltbp-menge,

elikz LIKE ltbp-elikz,

wempf LIKE ltbp-wempf,

name1 LIKE lfa1-name1,

END OF necesidades.

DATA:

ti_necesidades TYPE necesidades OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS: p_lfa1 FOR lfa1-lifnr OBLIGATORY.

<b>wempf_temp = p_lfa1-low.</b>

**While debugging here I have changed the value and got the output. Whatever value we are entering in select-options, it is convetred into Upper case. hence I tried with this and came to know abt the problem.

SELECT *

INTO CORRESPONDING FIELDS OF TABLE ti_necesidades

FROM ltbp

WHERE wempf = wempf_temp.

LOOP AT ti_necesidades.

WRITE: / ti_necesidades-tbnum,

ti_necesidades-werks,

ti_necesidades-wempf.

ENDLOOP.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

Former Member
0 Likes
749

Hi Jose,

If you use LOWER CASE addition with select options or parameters then then it will take the value as you have entered and it will not convert it into uppercase. I have tried the same. Have a look at below code.

I have done it using parameters. U can also do it using select options. For that u can use field symbols.

&----


*& Report ZTESTPG *

*& *

&----


*& *

*& *

&----


REPORT ztestpg .

TABLES: lfa1.

<b>DATA: wempf_temp LIKE ltbp-wempf.</b>

TYPES:

BEGIN OF necesidades,

tbnum LIKE ltbp-tbnum,

bwart LIKE ltbk-bwart,

bdatu LIKE ltbk-bdatu,

werks LIKE ltbp-werks,

lgnum LIKE ltbk-lgnum,

matnr LIKE ltbp-matnr,

maktx LIKE makt-maktx,

tamen LIKE ltbp-tamen,

meins LIKE ltbp-meins,

menge LIKE ltbp-menge,

elikz LIKE ltbp-elikz,

wempf LIKE ltbp-wempf,

name1 LIKE lfa1-name1,

END OF necesidades.

DATA:

ti_necesidades TYPE necesidades OCCURS 0 WITH HEADER LINE.

<b>PARAMETERS: p_lfa1 TYPE lfa1-lifnr LOWER CASE OBLIGATORY.</b>

<b>

wempf_temp = p_lfa1.</b>

SELECT *

INTO CORRESPONDING FIELDS OF TABLE ti_necesidades

FROM ltbp

WHERE wempf <b>= wempf_temp.</b>

LOOP AT ti_necesidades.

WRITE: / ti_necesidades-tbnum,

ti_necesidades-werks,

ti_necesidades-wempf.

ENDLOOP.

I hope it helps.

Best Regards,

Vibha

<b>*Please mark all the helpful answers</b>

Read only

Former Member
0 Likes
749

Hi jose just check this with ur code .

TABLES: LFA1.

TYPES:
BEGIN OF NECESIDADES,
 TBNUM LIKE LTBP-TBNUM,
 BWART LIKE LTBK-BWART,
 BDATU LIKE LTBK-BDATU,
 WERKS LIKE LTBP-WERKS,
 LGNUM LIKE LTBK-LGNUM,
 MATNR LIKE LTBP-MATNR,
 MAKTX LIKE MAKT-MAKTX,
 TAMEN LIKE LTBP-TAMEN,
 MEINS LIKE LTBP-MEINS,
 MENGE LIKE LTBP-MENGE,
 ELIKZ LIKE LTBP-ELIKZ,
 WEMPF LIKE LTBP-WEMPF,
 NAME1 LIKE LFA1-NAME1,
END OF NECESIDADES.

DATA:
ti_necesidades TYPE NECESIDADES occurs 0 WITH HEADER LINE.
 data : lifnr(12) type C . 
 DATA : VAL LIKE LFA1-LIFNR.  

SELECT-OPTIONS: p_LFA1 FOR LFA1-LIFNR OBLIGATORY.
     VAL   =  P_LFA1-LOW .

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input         = VAL                             "---> 10 digit 
 IMPORTING
   OUTPUT         = LIFNR.                    "-->12 digit 


WRITE:/ LIFNR.

SELECT *
INTO CORRESPONDING FIELDS OF TABLE ti_necesidades
FROM LTBP
WHERE WEMPF = LIFNR. "p_LFA1-low. "--> change it like this
break-point.        " check if the sy-subrc = 0.
check sy-subrc eq 0.
loop at ti_necesidades.
  write: / ti_necesidades-TBNUM,
           ti_necesidades-WERKS,
           ti_necesidades-WEMPF.
endloop.

regards,

Vijay.

Read only

Former Member
0 Likes
749

Hi,

use below logic.

data gv_WEMPF LIKE LTBP-WEMPF.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting = p_lfa1-low

importing = gv_WEMPF.

SELECT *

INTO CORRESPONDING FIELDS OF TABLE ti_necesidades

FROM LTBP

WHERE WEMPF = gv_WEMPF .

loop at ti_necesidades.

write: / ti_necesidades-TBNUM,

ti_necesidades-WERKS,

ti_necesidades-WEMPF.

endloop.

Regards

amole