Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Access objects in a flat structure

Former Member
0 Likes
2,134

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).

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,761

How is data-tab_vbak defined? I'm assuming a table type, yes? What are you trying to access here. Is there only one record in this table?

Regards,

Rich Heilman

19 REPLIES 19
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,762

How is data-tab_vbak defined? I'm assuming a table type, yes? What are you trying to access here. Is there only one record in this table?

Regards,

Rich Heilman

Read only

0 Likes
1,761

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.

Read only

0 Likes
1,761

Well I should of said "DATA" is the import parameter.

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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).

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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.

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

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

Read only

0 Likes
1,760

Lanka,

WA_VBAK still won't have a header so I won't be able to access WA_VBAK-VKORG.

Greg

Read only

0 Likes
1,760

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).

Read only

0 Likes
1,760

Thanks Srinivas! I love you!

Greg

Read only

0 Likes
1,760

That's exactly what I said in my second post, but in my suggestion, you only move it once, not twice.

Regards,

Rich Heilman

Read only

0 Likes
1,760

Sorry Rich your right! I just missed it.

Read only

Former Member
0 Likes
1,760

Hi Greg,

How the structure data-tab_vbak defined.

Lanka

Read only

0 Likes
1,760

If my assumptions are correct, then you can do something like this.



report zrich_0002.


data: data-tab_vbak type table of vbak.
data: w_vbak type vbak.

read table data-tab_vbak into w_vbak index 1.

Regards,

Rich Heilman