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

Exporting internal table in a oops

vijay_kumar133
Active Participant
0 Likes
1,429

hi friends,

I have to pass internal table to a method and export that internal table.

now when i am passing this internal table i am getting the last value of the table..

i am enclosing code here please go through and modify me regarding this..



REPORT  ZTEST_ABAP_PROXY.
DATA PRXY TYPE REF TO ZCO_MI_PROXY_OUTBOUND.

DATA: BEGIN OF I_MARA OCCURS 0,
  MATNR LIKE MARA-MATNR,
  ERNAM LIKE MARA-ERNAM,

  END OF I_MARA.



CREATE OBJECT PRXY.
DATA IT TYPE  ZMT_PROXY_OUTBOUND OCCURS 0 WITH HEADER LINE.


TRY.

    SELECT MATNR ERNAM INTO TABLE I_MARA FROM MARA UP TO 10 ROWS.

    LOOP AT I_MARA.

      IT-MT_PROXY_OUTBOUND-MATNR = I_MARA-MATNR.
      IT-MT_PROXY_OUTBOUND-ERNAM = I_MARA-ERNAM.
      APPEND IT.

    ENDLOOP.

    CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
      EXPORTING
        OUTPUT = IT.
    COMMIT WORK.


    
  CATCH CX_AI_SYSTEM_FAULT .
    DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .
    CREATE OBJECT FAULT.
    WRITE :/ FAULT->ERRORTEXT.
ENDTRY.


i need to pass all the values of internal table to output at once..

Thanks and Regards

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,044

Hi,

pass the internal table as IT[]

7 REPLIES 7
Read only

matt
Active Contributor
0 Likes
1,044

The problem is that just reading the code, you're not sure whether you're dealing with IT the table, or IT the header line. If you didn't use tables with header lines you wouldn't have made this mistake - it wouldn't have been possible. An excellent example of why you should get into the habit of NOT using header lines!


    CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
      EXPORTING
        OUTPUT = IT[].

matt

Read only

vijay_kumar133
Active Participant
0 Likes
1,044

Hi

now i am getting this error

"IT" is not type-compatible with formal parameter "OUTPUT".

i need to change any thing in method

the method look like this



METHOD EXECUTE_ASYNCHRONOUS.
SET EXTENDED CHECK OFF.
INCLUDE SPROXY_MACROS.
OUTBOUND_HANDLER_INIT_1
'EXECUTE_ASYNCHRONOUS'
'MI_Proxy_Outbound'
.
OUTBOUND_HANDLER_ADD_PARAM
'OUTPUT'
OUTPUT
'0'
'ZMT_PROXY_OUTBOUND'
'MT_Proxy_Outbound'
'http://relianceada.com/test/Proxy'
'MT_Proxy_Outbound'
'http://relianceada.com/test/Proxy'
.
OUTBOUND_HANDLER_EXECUTE.
SET EXTENDED CHECK ON.
ENDMETHOD.

i think we need to do some modifications in method also..

thanks and Regards

Vijay

Read only

matt
Active Contributor
0 Likes
1,044

Look at the type of IT. Look at the type of the parameter "OUTPUT" in METHOD EXECUTE_ASYNCHRONOUS. They're not the same.

How is the structure ZMT_PROXY_OUTBOUND defined? How is the structure of type OUTPUT defined? Look at them, and think carefully about how to get your data into the correct data structure.

Read only

Former Member
0 Likes
1,045

Hi,

pass the internal table as IT[]

Read only

0 Likes
1,044

Hi

ZCO_MI_PROXY_OUTBOUND (Proxy class)

ZMT_PROXY_OUTBOUND(structure)

and i have writen a code in abap report to pass data to output parameter..

but output parameter is of line type not a table type...

so it is taking onley one value but not entire internal table to output parameter.

OUTPUT is a Parameter of associated type ZMT_PROXY_OUTBOUND.

and ZMT_PROXY_OUTBOUND has a component MT_PROXY_OUTBOUND of type DT_PROXY_OUTBOUND and DT_PROXY_OUTBOUND has components MATNR and ERNAM.

Now plase say me how to modify my internal table

Thnaks and Regards

Vijay

Read only

Former Member
0 Likes
1,044

Hi Vijay,

I think the problem is with the output parameter.

Might be I'll give you the background and then explain you the problem. This may help.

In the older release of ABAP there used to be Tables as one of the tabs where one could import/export tables to/from the FM. The problem was that it would difficult to identify what table are being imported and what are bein exported.

So with later releases of ABAP this tab was removed and currently there are Exporting/Importing/Changing tabs. You can use changing in your case if you are passing the table to modify the same.

Now the problem.

As stated above the OUTPUT is a line type (means structure) while IT is a internal table with header lines. So the record in the wa of this table is only transferred to OUTPUT.

What needs to be done.

You need to change the type of the OUTPUT to table type. I am not sure if you know about table type.

You can create a Table Type is se11 under Data Type.

I hope this helps.

Regards,

Saurabh

Read only

Former Member
0 Likes
1,044

go to class builder and define method's parameter like changing, not like exporting