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

Issue while returing values from Function Module/BAPI

Former Member
0 Likes
407

Greetings all, I'm trying to get the values after returing from BAPI. Before come out of the FM, I can see the data in gt_gr_out table, but not after coming out. I want to display the data from table gt_gr_out, but nothing to display after come out from BAPI/FM.

Could anyone please advice me how do get the output data.

Thanks in advance.

=====================================================
*********************************************
TYPES:  ty_header TYPE zapo_gr_header.
DATA:   ty_item  TYPE zapo_gr_item.
DATA:  ty_gr_out  TYPE zapo_gr_status.
*********************************************
DATA: gt_gr_out  LIKE ty_gr_out OCCURS 0 WITH HEADER LINE,
      t_header             TYPE STANDARD TABLE OF ty_header,
      t_item               LIKE STANDARD TABLE OF ty_item.
*********************************************
 PERFORM goodsmvt_post TABLES  t_header
                                t_item
                                gt_gr_out.
*********************************************
FORM goodsmvt_post  TABLES   P_T_HEADER  STRUCTURE zapo_gr_header
                             P_T_ITEM    STRUCTURE zapo_gr_item
                             P_gt_gr_out STRUCTURE zapo_gr_status.


  CALL FUNCTION 'Z_APO_BAPI_GR_POST'
    TABLES
      I_GR_HEADER = P_T_HEADER
      I_GR_ITEM   = P_T_ITEM
      RETURN      = p_gt_gr_out.

ENDFORM.  
*********************************************
FUNCTION Z_APO_BAPI_GR_POST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      I_GR_HEADER STRUCTURE  ZAPO_GR_HEADER
*"      I_GR_ITEM STRUCTURE  ZAPO_GR_ITEM
*"      RETURN STRUCTURE  ZAPO_GR_STATUS
*"----------------------------------------------------------------------

      MOVE c_p TO gt_gr_out-feed_status.
      MOVE text-002 TO gt_gr_out-message1.
    ENDIF.
    CONCATENATE sy-datum
                sy-uzeit
              INTO gt_gr_out-proc_time.
    APPEND gt_gr_out.
=====================================================

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
391

Hello

Most likely the problem is due to the usage of outdated ABAP statements (e.g. itab with header lines & TABLES parameters).

I would recommend to make the following improvements:


=====================================================
*********************************************
TYPES:  ty_header TYPE zapo_gr_header,
             ty_t_header TYPE STANDARD TABLE OF ty_header
                               WITH DEFAULT KEY.
DATA:   ty_item  TYPE zapo_gr_item,
            ty_t_item  TYPE STANDARD TABLE OF ty_item
                            WITH DEFAULT KEY.
DATA:  ty_gr_out  TYPE zapo_gr_status,
           ty_t_gr_out  TYPE STANDARD TABLE OF ty_gr_out
                             WITH DEFAULT KEY.
*********************************************
"DATA: gt_gr_out  LIKE ty_gr_out OCCURS 0 WITH HEADER LINE,
"      t_header             TYPE STANDARD TABLE OF ty_header,
"      t_item               LIKE STANDARD TABLE OF ty_item.

DATA: gt_gr_out      TYPE ty_t_gr_out,
           t_header       TYPE ty_t_header,
           t_item           TYPE ty_t_item.


*********************************************
 "PERFORM goodsmvt_post TABLES  t_header
 "                               t_item
 "                               gt_gr_out.

PERFORM goodsmvt_post
                                 USING
                                       t_header
                                       t_item
                              CHANGING
                                      gt_gr_out.
*********************************************
"FORM goodsmvt_post  TABLES   P_T_HEADER  STRUCTURE zapo_gr_header
"                             P_T_ITEM    STRUCTURE zapo_gr_item
"                             P_gt_gr_out STRUCTURE zapo_gr_status.

FORM goodsmvt_post
                          USING VALUE(p_t_header)    TYPE ty_t_header
                                     VALUE(p_t_item)        TYPE ty_t_item
                      CHANGING
                                p_gt_gr_out                     TYPE ty_t_gr_out.
 
 
  CALL FUNCTION 'Z_APO_BAPI_GR_POST'
    TABLES
      I_GR_HEADER = P_T_HEADER
      I_GR_ITEM   = P_T_ITEM
      RETURN      = p_gt_gr_out.
 
ENDFORM.  
*********************************************
FUNCTION Z_APO_BAPI_GR_POST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      I_GR_HEADER STRUCTURE  ZAPO_GR_HEADER
*"      I_GR_ITEM STRUCTURE  ZAPO_GR_ITEM
*"      RETURN STRUCTURE  ZAPO_GR_STATUS
*"----------------------------------------------------------------------
 
" NOTE TABLES parameters are obsolete and should be replaced
"           by corresponding IMPORTING and EXPORTING parameters.

      MOVE c_p TO gt_gr_out-feed_status.
      MOVE text-002 TO gt_gr_out-message1.
    ENDIF.
    CONCATENATE sy-datum
                sy-uzeit
              INTO gt_gr_out-proc_time.
    APPEND gt_gr_out.
=====================================================

Regards

Uwe

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
392

Hello

Most likely the problem is due to the usage of outdated ABAP statements (e.g. itab with header lines & TABLES parameters).

I would recommend to make the following improvements:


=====================================================
*********************************************
TYPES:  ty_header TYPE zapo_gr_header,
             ty_t_header TYPE STANDARD TABLE OF ty_header
                               WITH DEFAULT KEY.
DATA:   ty_item  TYPE zapo_gr_item,
            ty_t_item  TYPE STANDARD TABLE OF ty_item
                            WITH DEFAULT KEY.
DATA:  ty_gr_out  TYPE zapo_gr_status,
           ty_t_gr_out  TYPE STANDARD TABLE OF ty_gr_out
                             WITH DEFAULT KEY.
*********************************************
"DATA: gt_gr_out  LIKE ty_gr_out OCCURS 0 WITH HEADER LINE,
"      t_header             TYPE STANDARD TABLE OF ty_header,
"      t_item               LIKE STANDARD TABLE OF ty_item.

DATA: gt_gr_out      TYPE ty_t_gr_out,
           t_header       TYPE ty_t_header,
           t_item           TYPE ty_t_item.


*********************************************
 "PERFORM goodsmvt_post TABLES  t_header
 "                               t_item
 "                               gt_gr_out.

PERFORM goodsmvt_post
                                 USING
                                       t_header
                                       t_item
                              CHANGING
                                      gt_gr_out.
*********************************************
"FORM goodsmvt_post  TABLES   P_T_HEADER  STRUCTURE zapo_gr_header
"                             P_T_ITEM    STRUCTURE zapo_gr_item
"                             P_gt_gr_out STRUCTURE zapo_gr_status.

FORM goodsmvt_post
                          USING VALUE(p_t_header)    TYPE ty_t_header
                                     VALUE(p_t_item)        TYPE ty_t_item
                      CHANGING
                                p_gt_gr_out                     TYPE ty_t_gr_out.
 
 
  CALL FUNCTION 'Z_APO_BAPI_GR_POST'
    TABLES
      I_GR_HEADER = P_T_HEADER
      I_GR_ITEM   = P_T_ITEM
      RETURN      = p_gt_gr_out.
 
ENDFORM.  
*********************************************
FUNCTION Z_APO_BAPI_GR_POST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      I_GR_HEADER STRUCTURE  ZAPO_GR_HEADER
*"      I_GR_ITEM STRUCTURE  ZAPO_GR_ITEM
*"      RETURN STRUCTURE  ZAPO_GR_STATUS
*"----------------------------------------------------------------------
 
" NOTE TABLES parameters are obsolete and should be replaced
"           by corresponding IMPORTING and EXPORTING parameters.

      MOVE c_p TO gt_gr_out-feed_status.
      MOVE text-002 TO gt_gr_out-message1.
    ENDIF.
    CONCATENATE sy-datum
                sy-uzeit
              INTO gt_gr_out-proc_time.
    APPEND gt_gr_out.
=====================================================

Regards

Uwe

Read only

Former Member
0 Likes
391

Hi Uwe,

thanks for the advice. my prob has been resolved. points rewarded.

your advice is appreciated, thanks.

Read only

uwe_schieferstein
Active Contributor
0 Likes
391

Hello

Actually there was another problem:


FUNCTION Z_APO_BAPI_GR_POST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      I_GR_HEADER STRUCTURE  ZAPO_GR_HEADER
*"      I_GR_ITEM STRUCTURE  ZAPO_GR_ITEM
*"      RETURN STRUCTURE  ZAPO_GR_STATUS
*"----------------------------------------------------------------------
 
      MOVE c_p TO gt_gr_out-feed_status.
      MOVE text-002 TO gt_gr_out-message1.
    ENDIF.
    CONCATENATE sy-datum
                sy-uzeit
              INTO gt_gr_out-proc_time.
    APPEND gt_gr_out.  " Does not fill RETURN parameter !!!
   
    APPEND gt_gr_out TO return.  " or:
    RETURN[] = gt_gr_out[].
    

Regards

Uwe