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

how to handle error in bapi using qp01

Former Member
0 Likes
706

Return message getting Using another operation code .... What it mean ?

4 REPLIES 4
Read only

Former Member
0 Likes
651

What is that you want to do ? Can you explain your problem in detail.

Read only

0 Likes
651

Hai ,

Through BDC i used bapi  BAPI_inspectionplan_create .qp01 tcode after commit work i check the return table it shows Using another operation id displays error .

TYPE-POOLS : truxs.
TYPES : BEGIN OF t_mat,
       matnr(18),       werks(4),       sttag(10),       tsk_description(40),       verwe(3),       statu(3),       losvn(13),       losbs(13),       planning_work_center(8),       op_activity(4),       steus(4),       arbpl(8),       op_description(40),       operation_measure_unit(3),       END OF t_mat.
DATA: wa_mat TYPE t_mat,
       it_mat TYPE STANDARD TABLE OF t_mat,
       wa_pop TYPE t_pop,
       it_pop TYPE STANDARD TABLE OF t_pop,
       wa_bdcdata TYPE bdcdata,
       it_bdcdata TYPE STANDARD TABLE OF bdcdata,
       wa_msg TYPE bdcmsgcoll,
       it_msg TYPE STANDARD TABLE OF bdcmsgcoll,
       file TYPE rlgrap-filename.

TYPES : BEGIN OF t_mseg,
               sno TYPE i,         msgtyp TYPE bdcmsgcoll-msgtyp,         txt(100),  

                END OF t_mseg.

DATA : v_flag TYPE sy-datum,
        v_posdate(10) TYPE c,"  TYPE sy-datum ,
        v_count(1) TYPE c,
        v_count1(3) TYPE c,
        v_pos TYPE string.

DATA: messtab TYPE STANDARD TABLE OF bdcmsgcoll .

DATA: subrc  TYPE  syst-subrc.
v_posdate = sy-datum.
CONCATENATE v_posdate+6(2)'.'v_posdate+4(2)'.'v_posdate(4) INTO v_posdate.

DATA : lv_data TYPE truxs_t_text_data.

DATA:  mode LIKE  apqi-putactive.
DATA: task  TYPE STANDARD TABLE OF   bapi1191_tsk_c,
       wa_task TYPE bapi1191_tsk_c,

       materialtaskallocation  TYPE STANDARD TABLE OF   bapi1191_mtk_c,
       wa_materialtaskallocation TYPE bapi1191_mtk_c,

       operation  TYPE STANDARD TABLE OF   bapi1191_opr_c ,
       wa_operation TYPE bapi1191_opr_c,

       group TYPE  bapi1191_tsk_c-task_list_group,
       groupcounter  TYPE  bapi1191_tsk_c-group_counter,
       return  TYPE STANDARD TABLE OF  bapiret2,
       wa_return TYPE bapiret2.
*DATA:testrun  TYPE  bapiflag .

SELECTION-SCREEN BEGIN OF BLOCK hc WITH FRAME TITLE text-002.
PARAMETERS :  p_file TYPE rlgrap-filename OBLIGATORY,
               w_mode TYPE ctu_params-dismode ."OBLIGATORY DEFAULT 'A'.
SELECTION-SCREEN END OF BLOCK hc.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

   CALL FUNCTION 'F4_FILENAME'
     EXPORTING
       program_name  = syst-cprog
       dynpro_number = syst-dynnr
       field_name    = 'P_FILE'
     IMPORTING
       file_name     = p_file.

START-OF-SELECTION.
   PERFORM getdata.
   PERFORM creation.
*&---------------------------------------------------------------------*
*&      Form  GETDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM getdata .
   file = p_file.
   CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
     EXPORTING
*     I_FIELD_SEPERATOR    = I_FIELD_SEPERATOR
       i_line_header        = 'X'
       i_tab_raw_data       = lv_data
       i_filename           = file
     TABLES
       i_tab_converted_data = it_mat.
ENDFORM.                                " GETDATA
*&---------------------------------------------------------------------*
*&      Form  CREATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM creation .
   LOOP AT it_mat INTO wa_mat.
     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
         input  = wa_mat-matnr
       IMPORTING
         output = wa_mat-matnr.
     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
       EXPORTING
         input  = wa_mat-op_activity
       IMPORTING
         output = wa_mat-op_activity.
     wa_materialtaskallocation-material = wa_mat-matnr.
     wa_materialtaskallocation-plant = wa_mat-werks.
     wa_materialtaskallocation-valid_from = sy-datum.
     APPEND wa_materialtaskallocation TO materialtaskallocation.

     wa_task-valid_from = sy-datum.
     wa_task-description = wa_mat-tsk_description.
     wa_task-task_list_usage =  wa_mat-verwe.
     wa_task-task_list_status = wa_mat-statu.
     wa_task-lot_size_from = wa_mat-losvn.
     wa_task-lot_size_to = wa_mat-losbs.
     wa_task-planning_work_center = wa_mat-planning_work_center.
     wa_task-plant = wa_mat-werks.
     wa_task-task_measure_unit = 'EA' .
     APPEND wa_task TO task.

     wa_operation-valid_from = sy-datum.
     wa_operation-activity = wa_mat-op_activity.                                        "
     wa_operation-plant = wa_mat-werks.
     wa_operation-control_key = wa_mat-steus.
     wa_operation-work_cntr = wa_mat-arbpl.
     wa_operation-description = wa_mat-op_description.
     wa_operation-operation_measure_unit   = wa_mat-operation_measure_unit.
     wa_operation-denominator  = '1'.
     wa_operation-nominator    = '1'.
     wa_operation-base_quantity = '1.000'.
*    wa_operation-operation_id = wa_mat-vornr.
     APPEND wa_operation TO operation.


     AT LAST.
       CALL FUNCTION 'BAPI_INSPECTIONPLAN_CREATE'
*        EXPORTING
*         testrun                = testrun
*         PROFILE                =
         IMPORTING
           group                  = group
           groupcounter           = groupcounter
         TABLES
           task                   = task
           materialtaskallocation = materialtaskallocation
           operation              = operation
*         REFERENCEOPERATION     =
*         PRODUCTIONRESOURCE     =
*         INSPCHARACTERISTIC     =
*         TEXTALLOCATION         =
*         TEXT                   =
           return                 return
*         INSP_CHAR_VALUES       =
         .

       COMMIT WORK.
     ENDAT.
   ENDLOOP.

ENDFORM.                    " CREATION

Read only

0 Likes
651

Hi Gokul,

In this part of code you can check and accumulate all the errors into another internal table

AT LAST.

       CALL FUNCTION 'BAPI_INSPECTIONPLAN_CREATE'

*        EXPORTING

*         testrun                = testrun

*         PROFILE                =

         IMPORTING

           group                  = group

           groupcounter           = groupcounter

         TABLES

           task                   = task

           materialtaskallocation = materialtaskallocation

           operation              = operation

*         REFERENCEOPERATION     =

*         PRODUCTIONRESOURCE     =

*         INSPCHARACTERISTIC     =

*         TEXTALLOCATION         =

*         TEXT                   =

           return                 return

*         INSP_CHAR_VALUES       =

         .

Loop at return into wa_return.

if wa_return-type = 'E' or wa_return-type = 'A'.

*-- Append message in an error internal table with the values in wa_return-messagev1,etc.

elseif wa_return-type = 'S' " And also check for the Message ID and Number for successful

                                             *    creation of Inspection Plans

*-- Append message in an Success internal table with the values in wa_return-

*--messagev1,etc.

endif.

endloop.

       COMMIT WORK.

     ENDAT.

If i understood you wrong please ask further.

BR.

Read only

Former Member
0 Likes
651

Hi Gokul,

Your Question is not clear.

Generally all the BAPIs return an internal table/structure of type BAPIRET2 which contains all the messages 'S' as well as 'E'/'A' (W,I etc too). You can play with this in your code.

BR.