2005 Aug 01 6:08 AM
I am trying to run simple ABAP code. But it is not working.
-
SELECT single obknr INTO mpos-obknr
FROM mpos WHERE warpl = record-warpl.
if sy-subrc = 0 then.
SELECT equnr
INTO i_plan_data-equnr
FROM objk
WHERE obknr = mpos-obknr.
i_plan_data-warpl = record-warpl.
APPEND i_plan_data.
ENDSELECT.
endif.
-
record and i_plan_data are internal tables.
Code is not fetching obknr from mpos table.
Please suggest what can be the error.
2005 Aug 01 6:16 AM
Hi Pratibha,
You probably have not defined the MPOS work area with the TABLES command. So the INTO clause is invalid. Rather than define MPOS as a work area, define a variable for OBKNR as seen below:
Variable for OBKNR
data: l_obknr like mpos-obknr.
select single obknr
into l_obknr
from mpos
where warpl = record-warpl.
if sy-subrc eq 0.
Record Found so now we populate table I_PLAN_DATA
select warpl equnr
into corresponding fields of table i_plan_data
from objk
where obknr = l_obknr.
endif.
2005 Aug 01 6:16 AM
first mpos-warpl is not a key field. so the select single may not give you the right record.
the statement should produce atleast one record if it exists.
Did you check the table (se16) to see whether an entry exists for your selection.
Regards
Raja
2005 Aug 01 6:16 AM
Hi Pratibha,
You probably have not defined the MPOS work area with the TABLES command. So the INTO clause is invalid. Rather than define MPOS as a work area, define a variable for OBKNR as seen below:
Variable for OBKNR
data: l_obknr like mpos-obknr.
select single obknr
into l_obknr
from mpos
where warpl = record-warpl.
if sy-subrc eq 0.
Record Found so now we populate table I_PLAN_DATA
select warpl equnr
into corresponding fields of table i_plan_data
from objk
where obknr = l_obknr.
endif.
2005 Aug 01 6:28 AM
Hi Patrick,
If MPOS had not been defiend with the tables statement, then there would have been a syntax error. However, that is not the case here.
Pratibha,
You can also try out a subquery for this -
tables objk.
select equnr
from objk
into objk-equnr
where obknr in ( select obknr
from mpos
where warpl = record-warpl ).
write : / objk-equnr.
endselect.
Let me know if the problem persists.
Regards,
Anand Mandalika.
2005 Aug 01 6:32 AM
2005 Aug 01 6:46 AM
Hi Pat,
Thanks for reply.
Actually internal table record is populated from text file with following code.
FORM read_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = p_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = RECORD
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
sort record by WARPL.
ENDFORM. " read_file
Program is not giving any error. Only it is not selecting obknr from mpos. I checked the table mpos and there is an entry for the warpl, I am trying for.
But some how code is not recognizing record-warpl.
2005 Aug 01 6:54 AM
ok. thats because WARPL has got conversion exit.
you need to use the following FM to convert it to the right format.
data: wf_warpl type mpos-warpl .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = record-warpl
IMPORTING
OUTPUT = wf_warpl .
suppose for. ex your WARPL is 41 this FM would convert it to "000000000041" as the WARPL size is 12.
use WF_WARPL is your select statement.
change the where clause to WHERE warpl = wf_warpl.
Regards
Raja
2005 Aug 01 6:54 AM
Pratibha,
Well I think maybe you need the leading zeros in WARPL. Try using FM CONVERSION_EXIT_ALPHA_INPUT.
loop at record.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = record-warpl
importing
output = record-warpl.
modify record transporting warpl.
endloop.
Now this should put in the necessary leading zeros into the WARPL field. Now try your select query into MPOS.
Let me know how this goes.
Pat.
2005 Aug 01 6:55 AM
2005 Aug 01 6:58 AM
practicing for /people/sap.user72/blog/2005/07/29/teched-05-get-your-thinking-hats-on-and-get-ready-to
Regards
Raja
2005 Aug 01 7:00 AM
2005 Aug 01 7:00 AM
2005 Aug 01 7:05 AM
Good to hear that i was able to help you. all the best.
Pat.
i was just joking, its not yet been decided whether they are going to have that in India or not.
Regards
Raja
2005 Aug 01 7:10 AM
Pratibha,
Glad to help!
Raja,
Yeah I know, I saw the weblog. Great idea though...fingers crossed that they bring it Down Under to Australia so I can collect my fre T-Shirt before being eliminated in the first round! Hahahahahaha!
Cheers,
Pat.
2005 Aug 01 7:32 AM
Hi Pat,
Are you from Australia by any chance ?
Regards,
Anand Mandalika.
2005 Aug 01 7:36 AM
2005 Aug 01 7:50 AM
Hi Anand,
I guess this forum is there to discuss <b>ABAP Programming</b>
Regards,
Nitin
2005 Aug 01 6:22 AM
Hi,
U can do as,
SELECT single OBKNR into mpos-obknr
from mpos for all entries in record
where warl = record-warpl.
if sy-subrc = 0.
SELECT equnr
into corresponding fields of table i_plan_dat
from objk
where obknr = mpos-obknr.
..................
endselecet.
endif.
Can try this one.
2005 Aug 01 6:29 AM
Hi,
Since record is an internal table,you should use for all entries to access it.
But single cannot be used with for all entries.
data itab type standard table of mpos.
select * from obknr into table itab from mpos for all entries in record where warpl = record-warpl.