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

Display the internal table data that returned from web service

Former Member
0 Likes
1,199

Hi all,

I am working on a web service, and trying to consume a service which will return me an internal table.

Below you can see my coding. All I wish is to display the internal table.

Please advice and thanks in advance.


REPORT  ZTEST_WEB_WS.
DATA: zproxy TYPE REF TO zcp_bc_co_zws_integration.
DATA: input  TYPE zcp_bc_zweb_integration,
      output TYPE zcp_bc_zweb_integration_respon,
      it_ret TYPE STANDARD TABLE OF sflight,
      wa_ret type sflight.

PARAMETER: p_carrid TYPE sflight-carrid DEFAULT 'LH'.

START-OF-SELECTION.

  TRY.
      CREATE OBJECT zproxy
        EXPORTING
          logical_port_name = 'ZLP_INTEGRATION'.
    CATCH cx_ai_system_fault .
  ENDTRY.
  TRY.
      input-carrid = p_carrid.

      CALL METHOD zproxy->zweb_integration
        EXPORTING
          input  = input
        IMPORTING
          output = output.

********How could I program, to get all the data in the internal table?********
*      IF NOT output-lt_sflight-item IS INITIAL.
*        LOOP AT it_ret INTO wa_ret.
*          WRITE:/ <sflight>-carrid,
*                  <sflight>-connid,
*                  <sflight>-fldate,
*                  <sflight>-price,
*                  <sflight>-currency.
*        ENDLOOP.
*      ENDIF.
   CATCH cx_ai_system_fault.
   CATCH cx_ai_application_fault.
  ENDTRY.

Hi all,

I am working on a web service, and trying to consume a service which will return me an internal table.

Below you can see my coding. All I wish is to display the internal table.

Please advice and thanks in advance.


REPORT  ZTEST_WEB_WS.
DATA: zproxy TYPE REF TO zcp_bc_co_zws_integration.
DATA: input  TYPE zcp_bc_zweb_integration,
      output TYPE zcp_bc_zweb_integration_respon,
      it_ret TYPE STANDARD TABLE OF sflight,
      wa_ret type sflight.

PARAMETER: p_carrid TYPE sflight-carrid DEFAULT 'LH'.

START-OF-SELECTION.

  TRY.
      CREATE OBJECT zproxy
        EXPORTING
          logical_port_name = 'ZLP_INTEGRATION'.
    CATCH cx_ai_system_fault .
  ENDTRY.
  TRY.
      input-carrid = p_carrid.

      CALL METHOD zproxy->zweb_integration
        EXPORTING
          input  = input
        IMPORTING
          output = output.

********How could I program, to get all the data in the internal table?********
*      IF NOT output-lt_sflight-item IS INITIAL.
*        LOOP AT it_ret INTO wa_ret.
*          WRITE:/ <sflight>-carrid,
*                  <sflight>-connid,
*                  <sflight>-fldate,
*                  <sflight>-price,
*                  <sflight>-currency.
*        ENDLOOP.
*      ENDIF.
   CATCH cx_ai_system_fault.
   CATCH cx_ai_application_fault.
  ENDTRY.

9 REPLIES 9
Read only

Former Member
0 Likes
1,150

Try below code:

it_ret[] =  output-lt_sflight[].
IF it_ret[] IS NOT INITIAL.
        LOOP AT it_ret INTO wa_ret.
          WRITE:/ wa_ret-carrid,
                  wa_ret-connid,
                  wa_ret-fldate,
                  wa_ret-price,
                  wa_ret-currency.
        ENDLOOP.
ENDIF.

Read only

0 Likes
1,150

Hi Chandra,

Thanks for your reply. I have tried the code you proposed to me. However I am getting this error.


"LT_SFLIGHT" is not an internal table "OCCURS n" specification is missing.

How could I solve this?

Read only

0 Likes
1,150

What the structure of Output, is it a deep structure?

Read only

0 Likes
1,150

Hi Chandra,

Yes you are right. It is a structure: deep.

When I double click into Output, I can see Controller (standard table), and LT_SFLIGHT (structure:deep).

If I double click into LT_SFLIGHT, I can see Controller (Standard table), and ITEM (standard table).

Please advise.

Read only

0 Likes
1,150

If I changed the code to


it_ret[] = output-lt_sflight-item[].
IF it_ret[] IS NOT INITIAL.
  LOOP AT it_ret INTO wa_ret.
    WRITE:/ wa_ret-carrid,
            wa_ret-connid,
            wa_ret-fldate,
            wa_ret-price,
            wa_ret-currency.
  ENDLOOP.
ENDIF.

Then the error is


The type of "OUTPUT-LT_SFLIGHT-ITEM" cannot be converted to the type of "IT_RET"

Read only

0 Likes
1,150

Please check if the type of ITEM is similar to the type of it_ret which is of type sflight.

Read only

0 Likes
1,150

Hi Chandra,

Thanks for your reply.

I have checked the content in ITEM, there is one more extra column, which is CONTROLLER (table) then following by SFLIGHT(all the fields). When I double click into CONTROLLER, there are 2 fields, Field(30) and Value(1).

Please advise.

Read only

0 Likes
1,150

Hi Myahsam,

You can try as shown below,

loop at output-lt_slight-item into wa_ret.

write: wa_ret-carrid,

wa_ret-connid.

endloop.

Note: You can declare wa_ret as a structure, you can get the name of this by double clicking on the output-it_slight-item, you will see CONTROLLER along with the other fields - carrid, connid etc.

Regards,

Chen

Read only

0 Likes
1,150

Leave it blank.