‎2006 Jan 30 7:53 PM
Ok, how do I read objects from a flat structure? I want to modify an IDocs control record with the following code but I get an error "The type of W_DATA_VBAK cannot be converted o the type of W_VBAK":
----
INCLUDE ZXTRKU01 *
----
DATA:
v_commid(15) TYPE C,
w_data_vbak LIKE data-tab_vbak,
w_vbak LIKE vbak.
w_data_vbak = data-tab_vbak.
MOVE w_data_vbak TO w_vbak.
*
Look up EDI communication ID from custom table
CALL FUNCTION 'Z_EK_GET_ORG_COMMID'
EXPORTING
i_company = w_vbak-vkorg
i_dist = w_vbak-vtweg
i_division = w_vbak-spart
IMPORTING
E_COMMID = v_commid.
CONTROL_RECORD_OUT-sndprn = v_commid(10).
‎2006 Jan 30 7:56 PM
‎2006 Jan 30 7:56 PM
‎2006 Jan 30 9:04 PM
DATA-TAB_VBAK is a function import parameter for the user exit and is of type TR_IDOC_SHPMNT_INDATA. This is defined as:
TYPES: BEGIN OF tr_idoc_shpmnt_indata,
vttk LIKE vttk,
ttds LIKE ttds,
tab_vttp LIKE vttp OCCURS 0,
tab_vtts LIKE vtts OCCURS 0,
tab_vtsp LIKE vtsp OCCURS 0,
tab_vbpa LIKE vbpa OCCURS 0,
tab_vtpa LIKE vbpa OCCURS 0,
tab_vekp LIKE vekp OCCURS 0,
tab_vepo LIKE vepo OCCURS 0,
tab_likp LIKE likp OCCURS 0,
tab_lips LIKE lips OCCURS 0,
tab_vbak LIKE vbak OCCURS 0,
tab_vbap LIKE vbap OCCURS 0,
tab_vblb LIKE vblb OCCURS 0,
tab_eikp LIKE eikp OCCURS 0,
tab_eipo LIKE eipo OCCURS 0,
<<< START OF INSERTION HP_0332970 >>>
tab_vbkd LIKE vbkd OCCURS 0,
<<< END OF INSERTION HP_0332970 >>>
tab_rdgprint LIKE rdgprint OCCURS 0,
END OF tr_idoc_shpmnt_indata.
‎2006 Jan 30 9:05 PM
‎2006 Jan 30 9:11 PM
Hi Greg,
Try this :
Data : W_VBAK LIKE VBAK.
Data : DATA1 type tr_idoc_shpmnt_indata.
DATA1 = data.
MOVE-CORRESPONDING DATA1-TAB_VBAK TO W_VBAK.
This will help you.
Lanka
‎2006 Jan 30 9:16 PM
In your import parameter DATA-TAB_VBAK or for that matter, all other fields are defined as internal tables except one or two. In newer versions moves like you did are not allowed. Here is the modified code, try it and let us know if it works.
DATA:
v_commid(15) TYPE C,
w_data_vbak LIKE LINE OF data-tab_vbak, <-- here is the change
w_vbak LIKE vbak.
w_data_vbak = data-tab_vbak.
MOVE w_data_vbak TO w_vbak.
*
*** Look up EDI communication ID from custom table
CALL FUNCTION 'Z_EK_GET_ORG_COMMID'
EXPORTING
i_company = w_vbak-vkorg
i_dist = w_vbak-vtweg
i_division = w_vbak-spart
IMPORTING
E_COMMID = v_commid.
CONTROL_RECORD_OUT-sndprn = v_commid(10).
‎2006 Jan 30 9:33 PM
Using:
Data : DATA1 type tr_idoc_shpmnt_indata.
DATA1 = data.
MOVE-CORRESPONDING DATA1-TAB_VBAK TO W_VBAK.
results in:
"TAB_VBAK" is not a structure or internal table with header line.
at this line:
MOVE-CORRESPONDING DATA1-TAB_VBAK TO W_VBAK.
I got similar messages with different variations I've tried already.
Thx,
Greg
‎2006 Jan 30 9:37 PM
Changing:
w_data_vbak LIKE data-tab_vbak,
To:
w_data_vbak LIKE LINE OF data-tab_vbak,
Resulted in:
The type of "DATA-TAB_VBAK cannot be converted to the type of "W_DATA_VBAK".
Thx,
Greg
‎2006 Jan 30 9:39 PM
Hi Greg,
I got it.
Data : WA_VBAK LIKE TABLE OF VBAK.
Data : DATA1 type tr_idoc_shpmnt_indata.
WA_VBAK[] = DATA1-VBAK[].
This will work for you.
I am using similar structures for my PO.
Lanka
‎2006 Jan 30 9:39 PM
btw - In the debugger I can drill into DATA-TAB_VBAK and TAB_VBAK looks just like a row of VBAK and the fields are populated.
‎2006 Jan 30 9:43 PM
hi Greg,
Please check the types definition for TAB_VBAK defined as internal table then you have to define your structure similar to that.(tab_vbak LIKE vbak OCCURS 0).
When you defined
Data : WA_VBAK LIKE TABLE OF VBAK.
<u>This will give you a table with out header line.</u>
Please try the above code that I have pasted that will work for you.
Lanka
Message was edited by: Lanka Murthy
‎2006 Jan 30 9:46 PM
True, but for DATA, TAB_VBAK is a field of type internal table, whereas the work area you defined is just a flat structure. So there is a type conflict there as per the new stricter syntax checks. The reason why you are seeing it in debugging is because it is showing you the header. But if you go to the tables view of the debugger and enter DATA-TAB_VBAK for the table name, you will see all the records.
Hope this helps,
Srinivas
‎2006 Jan 30 9:59 PM
Srinivas,
That's true. In the debugger I can see the fields of DATA-TAB_VBAK in the table view but if I try to enter DATA-TAB_VBAK-VKORG in the field view the field is not found. That is why I cannot access DATA-TAB_VBAK-VKORG directly.
Greg
‎2006 Jan 30 10:04 PM
Lanka,
WA_VBAK still won't have a header so I won't be able to access WA_VBAK-VKORG.
Greg
‎2006 Jan 30 10:35 PM
So your code should be like this, assuming you will always have one record in your DATA-TAB_VBAK internal table.
DATA: v_commid(15) TYPE C,
w_data_vbak LIKE LINE OF data-tab_vbak, <-- here is the change
w_vbak LIKE vbak.
<b>READ TABLE DATA-TAB_VBAK INTO w_data_vbak INDEX 1.</b>
MOVE w_data_vbak TO w_vbak.
*
*** Look up EDI communication ID from custom table
CALL FUNCTION 'Z_EK_GET_ORG_COMMID'
EXPORTING
i_company = w_vbak-vkorg
i_dist = w_vbak-vtweg
i_division = w_vbak-spart
IMPORTING
E_COMMID = v_commid.
CONTROL_RECORD_OUT-sndprn = v_commid(10).
‎2006 Jan 30 10:52 PM
‎2006 Jan 30 11:27 PM
‎2006 Jan 31 1:59 AM
‎2006 Jan 30 7:58 PM
‎2006 Jan 30 8:01 PM