‎2008 Apr 23 1:30 PM
Hello,
TYPES:
BEGIN OF ts_matnr,
matnr TYPE matnr,
objct TYPE cuobj,
END OF ts_matnr.
tables: mara.
DATA:
myStatus(20) type c,
mySTANDARDCLASS(20) type c,
gt_matnr TYPE STANDARD TABLE OF ts_matnr WITH DEFAULT KEY,
gs_matnr LIKE LINE OF gt_matnr,
gs_mara TYPE mara.
SELECT-OPTIONS:
pr_matnr FOR gs_mara-matnr.
START-OF-SELECTION.
SELECT matnr
matnr AS objct
FROM mara
INTO CORRESPONDING FIELDS OF TABLE gt_matnr WHERE matnr IN pr_matnr.I want to write both the normal String and the value as object into the table. But there is a error at the select saying the fields can't be converted to target field.
I don't know what the problem is. Can you see it?
Edited by: Daniel Gerne on Apr 23, 2008 2:31 PM
‎2008 Apr 23 1:35 PM
Hi Daniel,
you can write the Select query as
SELECT matnr
matnr
FROM mara
INTO CORRESPONDING FIELDS OF TABLE gt_matnr WHERE matnr IN pr_matnr.
LOOP AT gt_matnr INTO gs_matnr.
gs_matnr-objct = gs_matnr-matnr.
write:
/ gs_matnr-matnr,
gs_matnr-objct.
MODIFY gt_matnr FROM gs_matnr.
ENDLOOP.Regards ,
Sunil
‎2008 Apr 23 1:36 PM
MATNR has type CHAR 18, CUOBJ has type NUMC 18 - how should this work? i.e. How should a letter (let´s say 'Z') be converted to e numeric?
‎2008 Apr 23 1:37 PM
Hi,
You are calling Matnr twice and your internal table is having only one matnr.
Error is becoz of that.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 23, 2008 9:57 AM
‎2008 Apr 23 1:38 PM
Hello Daniel-
Instead of gt_matnr TYPE STANDARD TABLE OF ts_matnr WITH DEFAULT KEY,
Try gt_matnr type table of ts_matnr.
Cheers,
~Srini....
‎2008 Apr 23 1:38 PM
Hi,
Y dont you try using your select statement as follws:
SELECT matnr
objct
FROM mara
INTO CORRESPONDING FIELDS OF TABLE gt_matnr WHERE matnr IN pr_matnr.
The reason for this error is the data type mismatch b/w the source and target.
Hope this helps.
Regards
Sourabh
‎2008 Apr 23 1:51 PM
can you tell us detailed requirment, maybe we can give you more suggestion.
‎2008 Apr 23 1:54 PM
Hi,
1.The main problem is type conflict in the source to target.
This cuobj is NUM 18,matnr is CHAR 18.
2.If you do with same type .Then.
TYPES:
BEGIN OF ts_matnr,
matnr TYPE matnr,
objct TYPE bismt,
END OF ts_matnr.
tables: mara.
DATA:
myStatus(20) type c,
mySTANDARDCLASS(20) type c,
gt_matnr TYPE STANDARD TABLE OF ts_matnr WITH DEFAULT KEY,
gs_matnr LIKE LINE OF gt_matnr,
gs_mara TYPE mara.
SELECT-OPTIONS:
pr_matnr FOR gs_mara-matnr.
START-OF-SELECTION.
SELECT matnr
matnr AS objct
FROM mara
INTO CORRESPONDING FIELDS OF TABLE gt_matnr WHERE matnr IN pr_matnr.
loop at gt_matnr into gs_matnr.
write:/ gs_matnr.
endloop.
Regards,
Shiva.
‎2008 Apr 23 2:02 PM
Hi shiva,
your code seems to be working. What is this type bismt anyway?
thank you.
‎2008 Apr 23 2:15 PM
unfortunately, I just saw that I just walked around my problem instead of solving it. The reason I want to have this MATNR is that I need to use it as Objectkey for a BAPI call:
LOOP AT gt_matnr INTO gs_matnr.
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL_KEY'
EXPORTING
* CLOBJECTKEY = gt_matnr-objct "nicht Tabelle, sondern Arbeitsbereich
CLOBJECTKEY = gs_matnr-objct "hat Typ OBJCT <=> BAPI1003_KEY-OBJECT_GUID
CLASSNUM = 'FARBIGE_UNTERLAGEN'
* KEYDATE = SY-DATUM
* LANGUAGE = SY-LANGU
IMPORTING
STATUS = myStatus
STANDARDCLASS = mySTANDARDCLASS.
* TABLES
* ALLOCVALUESNUM =
* ALLOCVALUESCHAR =
* ALLOCVALUESCURR =
* RETURN =.
ENDLOOP.But with the type from Shiva's code the debugger says that the given parameter has a wrong type.I just can't get this BAPI to work. I want to use it to get the classification information about a material.
‎2008 Apr 23 2:32 PM
Why don´t you do it that way?:
DATA:
gt_matnr TYPE STANDARD TABLE OF matnr,
gw_matnr TYPE matnr,
gv_objkey TYPE cuobj.
SELECT matnr
FROM mara
INTO OF TABLE gt_matnr WHERE matnr IN pr_matnr.
LOOP AT gt_matnr INTO gw_matnr.
* type conversion
MOVE gw_matnr TO gv_objkey.
* call bapi
CALL FUNCTION 'BAPI_OBJCL_GETDETAIL_KEY'
EXPORTING
CLOBJECTKEY = gv_objkey
CLASSNUM = 'FARBIGE_UNTERLAGEN'
* KEYDATE = SY-DATUM
* LANGUAGE = SY-LANGU
IMPORTING
STATUS = myStatus
STANDARDCLASS = mySTANDARDCLASS.
* TABLES
* ALLOCVALUESNUM =
* ALLOCVALUESCHAR =
* ALLOCVALUESCURR =
* RETURN =.
ENDLOOP.
‎2008 Apr 23 2:42 PM
Hello Mike,
thank you for the code. But there are a few syntax errors in it.
About:
INTO OF TABLE gt_matnr WHERE matnr IN pr_matnr.It doesn't know pr_matnr. It says it wants to have a table it can walk through, so I thought maybe you meant gt_matnr. But there the debugger says: Table pr_matnr has the wrong Linestructure.
‎2008 Apr 23 2:53 PM
Sorry, than just add the missing statement:
SELECT-OPTIONS:
pr_matnr FOR gs_mara-matnr.
I posted this coding just to show you how ist should work. My intention was not to do your job!