‎2007 Apr 02 3:09 PM
Hello Friends,
I am having a problem in the select statement and I dont see any error in the statement.
IN the below code the select statement where I am getting data into t_plaf works fine and pulls the data. But the second statement for internal table t_mara doesnt pull data even though data exist in the data base MARA table. IT has values for the combination of material in t_Plaf and the normt in the select option. I am confused why this is happening. IS it something with the declaration or Inner join or what?
Any Suggestions will be highly appericiated.
Thanks, MAdhu.
DATA :BEGIN OF t_plaf OCCURS 0,
normt LIKE mara-normt,
matnr LIKE plaf-matnr,
pwwrk LIKE plaf-pwwrk,
paart LIKE plaf-paart,
verid LIKE plaf-verid,
END OF t_plaf.
DATA :BEGIN OF t_mara OCCURS 0,
matnr LIKE mara-matnr,
normt LIKE mara-normt,
END OF t_mara.
SELECTION-SCREEN : BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_werks FOR zcast-werks OBLIGATORY,
s_planpl FOR mara-normt,
s_psttr FOR zcast-zefdat OBLIGATORY,
s_matnr FOR mara-matnr,
s_dispo FOR plaf-dispo.
SELECTION-SCREEN : END OF BLOCK 1.
SELECT maranormt plafmatnr
plafpwwrk plafpaart plaf~verid
INTO TABLE t_plaf
FROM plaf
INNER JOIN mara
ON plafmatnr EQ maramatnr
WHERE plaf~paart = 'ZX'
AND plaf~pwwrk IN s_werks
AND plaf~psttr IN s_psttr
AND plaf~dispo IN s_dispo
AND plaf~matnr IN s_matnr.
IF NOT t_plaf[] IS INITIAL.
SELECT matnr normt
INTO table t_mara
FROM mara
FOR ALL ENTRIES IN t_plaf
WHERE matnr = t_plaf-matnr
AND normt IN s_planpl.
ENDIF.
‎2007 Apr 02 3:19 PM
Hi,
Please try this.
...
IF NOT t_plaf[] IS INITIAL.
SELECT matnr normt
INTO table t_mara
FROM mara
FOR ALL ENTRIES IN t_plaf
WHERE matnr = t_plaf-matnr
AND normt = t_plaf-normt. < --- change in here
ENDIF.
...
Regards,
Ferry Lianto
‎2007 Apr 02 3:15 PM
Hi,
whyyou are using MARA table twice in the both selects.
NORMT is in MARA table not in plaf table.
First select is enough to get the values.
no need of second MARA select since you are fetching NORMT and MATNR fields in the first select itself.
SELECT maranormt plafmatnr
plafpwwrk plafpaart plaf~verid
INTO TABLE t_plaf
FROM plaf
INNER JOIN mara
ON plafmatnr EQ maramatnr
WHERE plaf~paart = 'ZX'
AND plaf~pwwrk IN s_werks
AND plaf~psttr IN s_psttr
AND plaf~dispo IN s_dispo
AND plaf~matnr IN s_matnr.
reward if useful
regards,
Anji
‎2007 Apr 02 3:21 PM
Thanks I never realized that.
That makes sense.
However I am curious to know why I dont see any data in the second select statement if data exists in the database.
Any suggestions.
‎2007 Apr 02 3:31 PM
Thanks Anji for your suggestion. However i changes my First select statement a bit and now the first dosent work.
SELECT maranormt plafmatnr
plafpwwrk plafpaart plaf~verid
INTO TABLE t_plaf
FROM plaf
INNER JOIN mara
ON plafmatnr EQ maramatnr
WHERE plaf~paart = 'ZX'
AND plaf~pwwrk IN s_werks
AND plaf~psttr IN s_psttr
AND plaf~dispo IN s_dispo
AND plaf~matnr IN s_matnr
<u><b>and mara~normt IN s_planpl.</b></u>
ANy suggestions.
‎2007 Apr 02 3:18 PM
Hi Madhu,
Please use the query for PLAF and MARA.
<b>Please remove your join operation and execute it separately as below</b>
SELECT mara~normt
plaf~matnr
plaf~pwwrk
plaf~paart
plaf~verid
INTO TABLE t_plaf
FROM plaf
WHERE plaf~paart = 'ZX'
AND plaf~pwwrk IN s_werks
AND plaf~psttr IN s_psttr
AND plaf~dispo IN s_dispo
AND plaf~matnr IN s_matnr.
IF NOT t_plaf[] IS INITIAL.
SELECT matnr normt
INTO table t_mara
FROM mara
FOR ALL ENTRIES IN t_plaf
WHERE matnr = t_plaf-matnr
AND normt IN s_planpl.
ENDIF.
Reward Point if helpfull*****************
‎2007 Apr 02 3:19 PM
Hi,
Please try this.
...
IF NOT t_plaf[] IS INITIAL.
SELECT matnr normt
INTO table t_mara
FROM mara
FOR ALL ENTRIES IN t_plaf
WHERE matnr = t_plaf-matnr
AND normt = t_plaf-normt. < --- change in here
ENDIF.
...
Regards,
Ferry Lianto
‎2007 Apr 02 3:24 PM
Ferry,
Can you explain why you suggested to make the changes. I can also use the data in the selection option to fetch the data . Am I right.
I understand I have data in t_plaf for normt but why cant I use it from selection Screen.
Thanks,
Madhu
‎2007 Apr 02 3:20 PM
Hi
Some times it may not match, if the data type doesnot match.
Data type may be same between plaf-matnr and mara-matnr, but also check the length, for mara-matnr it is 18, check for plaf-matnr.
Regards
MD
‎2007 Apr 02 3:25 PM
Hi Madhu,
Please use this function module to convert your material number and then try it will work...
CONVERSION_EXIT_MATN2_INPUT
Thanks and Regards,
Kunjal Patel
‎2007 Apr 02 3:35 PM
REPORT YCHATEST.
SELECT MARANORMT PLAFMATNR
PLAFPWWRK PLAFPAART PLAF~VERID
INTO TABLE T_PLAF
FROM PLAF
INNER JOIN MARA
ON PLAFMATNR EQ MARAMATNR
WHERE PLAF~PAART = 'ZX'
AND PLAF~PWWRK IN S_WERKS
AND PLAF~PSTTR IN S_PSTTR
AND PLAF~DISPO IN S_DISPO
AND PLAF~MATNR IN S_MATNR.
<b>LOOP AT T_PLAF INTO WA_T_PLAF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_T_PLAF-MATNR
IMPORTING
OUTPUT = WA_T_PLAF-MATNR.
MODIFY T_PLAF FROM WA_T_PLAF.
ENDLOOP.</b>
IF NOT T_PLAF[] IS INITIAL.
SELECT MATNR NORMT
INTO TABLE T_MARA
FROM MARA
FOR ALL ENTRIES IN T_PLAF
WHERE MATNR = T_PLAF-MATNR
AND NORMT IN S_PLANPL.
ENDIF.
******************not working***************************
‎2007 Apr 02 3:41 PM
Thanks Chandreshkar.
At last I see Not working in your answer. Is it working for you or its not.
I tried dosent work.
Madhu.
‎2007 Apr 02 3:55 PM
Hi Madhu,
Yes you can use selection option to fetch data. The reason I was suggesting is that you already have data in normt in internal table t_plaf (I may not see clearly first select statement).
Perhaps you can try this to filter t_mara based on s_planpl.
...
IF NOT t_plaf[] IS INITIAL.
SELECT matnr normt
INTO table t_mara
FROM mara
FOR ALL ENTRIES IN t_plaf
WHERE matnr = t_plaf-matnr
AND normt = t_plaf-normt.
DELETE t_plaf where not normt in s_planpl.
ENDIF.
...
Regards,
Ferry Lianto
‎2007 Apr 02 5:37 PM
Hi MR,
in your internal table declaration
you have declared t_plaf-matnr LIKE plaf-matnr,
if you feel your statement is right :
possibilities could be
a)now MATNR is char18 so is your t_plaf-matnr storing a value with char18,
b)try to declare t_plaf-matnr LIKE mara-matnr.
Cheers.
Aditya.