2006 Nov 18 4:45 AM
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.
2006 Nov 18 5:02 AM
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
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
2006 Nov 18 4:55 AM
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
2006 Nov 18 4:56 AM
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,
2006 Nov 18 5:02 AM
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
2006 Nov 18 5:34 AM
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>
2006 Nov 18 10:12 AM
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.
2006 Nov 18 10:39 AM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |