BAPI_INSPECTIONPLAN_CREATE-Quality Inspection Plan (Single File) With Long Text Upload.


Generally in all projects where Quality Management is implemented, there is a need of Mass upload of Quality Inspection Plan.  SAP Transaction code for this is QP01.

So here we have made a tool for uploading quality plan using BAPI BAPI_INSPECTIONPLAN_CREATE which also support of uploading long text.

To Download With File TemplateClick Here.


CODE:

REPORT zqm_inspection_plan_wlt_upload.

TYPE-POOLS slis.
TABLES :sscrfields.

*----------------------------------------------------------------------*
*     SELECTION SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK s2 WITH FRAME TITLE TEXT-001.
PARAMETERSp_file  TYPE ibipparms-path  .
SELECTION-SCREEN END OF BLOCK s2 .

*----------------------------------------------------------------------*
*     GLOBAL DATA
*----------------------------------------------------------------------*
DATA  v_mode.
DATA v_filename TYPE string.
* Data Declarations for import internal table parameters to BAPI

DATA t_task                   TYPE TABLE OF bapi1191_tsk_c WITH HEADER LINE,
       t_materialtaskallocation TYPE TABLE OF bapi1191_mtk_c  WITH HEADER LINE,
       t_inspcharacteristic     TYPE TABLE OF bapi1191_cha_c  WITH HEADER LINE,
       t_operation              TYPE TABLE OF bapi1191_opr_c  WITH HEADER LINE,
       t_textheader             TYPE TABLE OF bapi1191_txt_hdr_c WITH HEADER LINE,
       t_textdata               TYPE TABLE OF bapi1012_txt_c WITH HEADER LINE,
       t_return                 TYPE TABLE OF bapiret2 WITH HEADER LINE.

DATA g_answer    TYPE c,
       g_lines_tab TYPE popuptext OCCURS WITH HEADER LINE.

DATA v_count1(8TYPE n,
       v_count2(8TYPE n.

* Local Variables
DATA v_group      TYPE bapi1191_tsk_c-task_list_group,
       v_grpcounter TYPE bapi1191_tsk_c-group_counter,
       v_file       TYPE localfile,
       v_row        TYPE n,
       v_plant      LIKE t_task-plant,
       v_lines      TYPE i,
       v_per        TYPE p,
       v_txt(50)    TYPE c.

* Declare Internal table for Message Header for ALV Display
DATABEGIN OF it_loghead  OCCURS 0,
        material LIKE bapi1191_mtk_c-material,
        plant    LIKE bapi1191_tsk_c-plant,
        msgtype  LIKE bapiret2-type,
        msg(100TYPE c,
        expand   TYPE c,
      END OF it_loghead .

* Declare Internal table for Message Details for ALV Display
DATABEGIN OF it_logdetail OCCURS 0,
        material LIKE bapi1191_mtk_c-material,
        plant    LIKE bapi1191_tsk_c-plant,
        msgtype  LIKE bapiret2-type,
        msg(100TYPE c,
      END OF it_logdetail.

* Structure to Load Data from the Text File
TYPES BEGIN OF ty_insplan,
          plant                   LIKE t_task-plant,
          material                LIKE t_materialtaskallocation-material,
          tsk_description         LIKE t_task-description,
          task_list_usage         LIKE t_task-task_list_usage,
          task_list_status        LIKE t_task-task_list_status,
          lot_size_from           LIKE t_task-lot_size_from,
          lot_size_to             LIKE t_task-lot_size_to,
          planning_work_center    LIKE t_task-planning_work_center,
          task_measure_unit       LIKE t_task-task_measure_unit,
          op_activity             LIKE t_operation-activity,
          control_key             LIKE t_operation-control_key,
          work_cntr               LIKE t_operation-work_cntr,
          op_description          LIKE t_operation-description,
          operation_measure_unit  LIKE t_operation-operation_measure_unit,
          ins_activity            LIKE t_inspcharacteristic-activity,
          inspchar                LIKE t_inspcharacteristic-inspchar,
          quantitative_ind        LIKE t_inspcharacteristic-quantitative_ind,
          mstr_char               LIKE t_inspcharacteristic-mstr_char,
          cha_master_import_modus LIKE t_inspcharacteristic-cha_master_import_modus,
          char_descr1             TYPE comnt,
          char_descr2             TYPE comnt,
          char_descr3             TYPE comnt,
          char_descr4             TYPE comnt,
          char_descr5             TYPE comnt,
          char_descr6             TYPE comnt,
          char_descr7             TYPE comnt,
          char_descr8             TYPE comnt,
          char_descr9             TYPE comnt,
          char_descr10            TYPE comnt,
          char_descr11            TYPE comnt,
          char_descr12            TYPE comnt,
          method                  LIKE t_inspcharacteristic-method,
          target_val              LIKE t_inspcharacteristic-target_val,
          up_tol_lmt              LIKE t_inspcharacteristic-up_tol_lmt,
          lw_tol_lmt              LIKE t_inspcharacteristic-lw_tol_lmt,
          meas_unit               LIKE t_inspcharacteristic-meas_unit,
          smpl_procedure          LIKE t_inspcharacteristic-smpl_procedure,
          smpl_unit               LIKE t_inspcharacteristic-smpl_unit,
          smpl_quant              LIKE t_inspcharacteristic-smpl_quant,
          up_tol_lmt_ind          LIKE t_inspcharacteristic-up_tol_lmt_ind,
          lw_tol_lmt_ind          LIKE t_inspcharacteristic-lw_tol_lmt_ind,
          sampling_procedure_ind  LIKE t_inspcharacteristic-sampling_procedure_ind,
          long_term_insp_ind      LIKE t_inspcharacteristic-long_term_insp_ind,
          sel_set1                TYPE qcgrausw,
          psel_set1               TYPE qwerkausw,
        END OF ty_insplan.

* Internal Table to Load and Hold Data from the Text File
DATA it_insplan TYPE TABLE OF ty_insplan WITH HEADER LINE.

DATA BEGIN OF gt_mara OCCURS 0,
         matnr TYPE matnr,
         meins TYPE meins,
       END OF gt_mara.

INITIALIZATION.
  PERFORM f_fill_infotext.

AT SELECTION-SCREEN.
  IF sscrfields-ucomm 'INFO'.
    CALL FUNCTION 'DD_POPUP_WITH_INFOTEXT'
      EXPORTING
        titel        'Text File Format '(020)
        start_column 10
        start_row    10
        end_column   85
        end_row      27
        infoflag     ' '
      IMPORTING
        answer       g_answer
      TABLES
        lines        g_lines_tab.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM choose_data_file.

START-OF-SELECTION.
* Clear Internal Tables holding Messages
  CLEAR it_loghead[].
  CLEAR it_logdetail[].

* Call Subroutine to Load data into Internal table from text file
  PERFORM load_data_from_file.

* Determine the number of records in the internal table
  DESCRIBE TABLE it_insplan LINES v_lines.

  SELECT matnr meins
    FROM mara
    INTO TABLE gt_mara.

  SORT gt_mara BY matnr.
* Loop at internal table to load all data
  LOOP AT it_insplan.
* Call Subroutine to Display the Progress
    PERFORM display_progress_timer.
    ON CHANGE OF it_insplan-material.
      CLEAR v_count1,v_count2.

      IF it_insplan-ins_activity IS INITIAL AND t_task IS NOT INITIAL.
* Call Subroutine to Load the inspection plan
        PERFORM call_bapi_and_commit.
* Re-initialise the internal tables
        PERFORM clear_internal_tables.
      ENDIF.

      IF it_insplan-plant IS NOT INITIAL.
        v_plant it_insplan-plant.
      ENDIF.
    ENDON.

    IF it_insplan-plant NE space.
* Moving Corresponding fields to Material internal table
      t_materialtaskallocation-material it_insplan-material.
      t_materialtaskallocation-plant it_insplan-plant.
      t_materialtaskallocation-valid_from sy-datum.
      APPEND t_materialtaskallocation.

* Moving Corresponding fields to task internal table
      t_task-valid_from sy-datum.
      t_task-description it_insplan-tsk_description.
      t_task-task_list_usage it_insplan-task_list_usage.
      t_task-task_list_status it_insplan-task_list_status.
      t_task-lot_size_from it_insplan-lot_size_from.
      t_task-lot_size_to it_insplan-lot_size_to.
      t_task-planning_work_center it_insplan-planning_work_center.
      t_task-plant it_insplan-plant.

      IF it_insplan-task_measure_unit IS INITIAL.
        READ TABLE gt_mara WITH KEY matnr it_insplan-material BINARY SEARCH.
        IF sy-subrc 0.
          t_task-task_measure_unit gt_mara-meins.
        ENDIF.
      ELSE.
        t_task-task_measure_unit it_insplan-task_measure_unit.
      ENDIF.

      APPEND t_task.

* Moving Corresponding fields to Operation internal table
      t_operation-valid_from sy-datum.
      t_operation-activity it_insplan-op_activity.
      t_operation-plant it_insplan-plant.
      t_operation-control_key it_insplan-control_key.
      t_operation-work_cntr it_insplan-work_cntr.
      t_operation-description it_insplan-op_description.
      t_operation-operation_measure_unit it_insplan-operation_measure_unit.
      t_operation-denominator  '1'.
      t_operation-nominator    '1'.
      t_operation-base_quantity '1.000'.
      APPEND t_operation.

    ELSE.
*Moving Corresponding fields to Inspection Characteristics internal table
      t_inspcharacteristic-activity it_insplan-ins_activity.
      t_inspcharacteristic-inspchar it_insplan-inspchar.
      t_inspcharacteristic-valid_from  sy-datum.
      t_inspcharacteristic-mstr_char |{ it_insplan-mstr_char  ALPHA IN }|.

      DATAv_plant1 TYPE werks_d.
      DATAstellen TYPE qpmk-stellen.
      CLEARv_plant1.
      CLEARstellen.
      DATAtemp1(20)temp2(20)temp3(20).
      DATAlen1 TYPE ilen2 TYPE i.

      CLEARtemp1temp2temp3.
      CLEARlen1len2.

      MOVE it_insplan-up_tol_lmt TO temp1.
      SPLIT temp1 AT '.' INTO temp2 temp3.
      IF temp3 IS NOT INITIAL.
        len1 strlentemp3 ).
      ENDIF.

      CLEARtemp1temp2temp3.
      MOVE it_insplan-lw_tol_lmt TO temp1.
      SPLIT temp1 AT '.' INTO temp2 temp3.
      IF temp3 IS NOT INITIAL.
        len2 strlentemp3 ).
      ENDIF.

      IF len2 GE len1.
        stellen len2.
      ELSE.
        stellen len1.
      ENDIF.

      SELECT SINGLE zaehler
        FROM qpmk
        INTO v_plant1
       WHERE mkmnr it_insplan-mstr_char.

      t_inspcharacteristic-pmstr_char v_plant1.
      t_inspcharacteristic-method it_insplan-method.
      t_inspcharacteristic-pmethod v_plant1.
      t_inspcharacteristic-meas_value_confirm_ind ='X'.
      t_inspcharacteristic-smpl_procedure  it_insplan-smpl_procedure.
      IF it_insplan-smpl_unit IS INITIAL.
        READ TABLE gt_mara WITH KEY matnr it_insplan-material BINARY SEARCH.
        IF sy-subrc 0.
          t_inspcharacteristic-smpl_unit gt_mara-meins.
        ENDIF.
      ELSE.
        t_inspcharacteristic-smpl_unit it_insplan-smpl_unit.
      ENDIF.


      t_inspcharacteristic-dec_places stellen.
      t_inspcharacteristic-smpl_quant it_insplan-smpl_quant.
      t_inspcharacteristic-sampling_procedure_ind it_insplan-sampling_procedure_ind.
      t_inspcharacteristic-cha_master_import_modus it_insplan-cha_master_import_modus.

      SELECT SINGLE kurztext
        FROM qpmt
        INTO t_inspcharacteristic-char_descr
        WHERE mkmnr it_insplan-mstr_char.

      t_inspcharacteristic-quantitative_ind =
      it_insplan-quantitative_ind.

      IF it_insplan-quantitative_ind EQ space.
        t_inspcharacteristic-attribute_required_ind 'X'.
        t_inspcharacteristic-sel_set1 it_insplan-sel_set1.
        t_inspcharacteristic-psel_set1 it_insplan-psel_set1.
      ENDIF.
      t_inspcharacteristic-target_val it_insplan-target_val.
      t_inspcharacteristic-up_tol_lmt it_insplan-up_tol_lmt.
      t_inspcharacteristic-up_tol_lmt_ind it_insplan-up_tol_lmt_ind.
      t_inspcharacteristic-lw_tol_lmt_ind it_insplan-lw_tol_lmt_ind.
      t_inspcharacteristic-long_term_insp_ind it_insplan-long_term_insp_ind.

      CALL FUNCTION 'CONVERSION_EXIT_LUNIT_INPUT'
        EXPORTING
          input          it_insplan-meas_unit
          language       sy-langu
        IMPORTING
          output         t_inspcharacteristic-meas_unit.

      t_inspcharacteristic-lw_tol_lmt it_insplan-lw_tol_lmt.
      APPEND t_inspcharacteristic.

      v_count1 v_count2 + 1.
      v_count2 v_count1 + 12.
      t_textheader-object_type '19'.
      t_textheader-inspchar it_insplan-inspchar.
      t_textheader-activity it_insplan-ins_activity.
      t_textheader-cha_text_type 'C'.
      t_textheader-line_from v_count1.
      t_textheader-line_to v_count2.
      t_textheader-langu sy-langu.
      t_textheader-valid_from sy-datum.
      APPEND t_textheader.
      CLEAR  t_textheader.
      CLEAR  t_textdata.

      t_textdata-text_line t_inspcharacteristic-char_descr.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr1.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr2.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr3.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr4.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr5.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr6.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr7.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr8.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr9.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr10.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr11.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.

      t_textdata-text_line it_insplan-char_descr12.
      t_textdata-format_col '*'.
      APPEND t_textdata.
      CLEAR  t_textdata.
    ENDIF.

  ENDLOOP.

  IF t_task IS NOT INITIAL.
* Call Subroutine to upload last inspection plan details
    PERFORM call_bapi_and_commit.
  ENDIF.

* Call Subroutine to Display Log in ALV
  PERFORM display_log_list.

*&------------------------------------------------------------------*
*&      Form  CHOOSE_DATA_FILE
*&------------------------------------------------------------------*
*  Subroutine to Show File Dialog and select file from the PC
*-------------------------------------------------------------------*
FORM choose_data_file .
  DATAlt_filetable TYPE filetable,
        lf_rc        TYPE i,
        v_fname(50)  TYPE c,
        v_fext(3)    TYPE c.

* Function module to show File open Dialog
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            'Select Inspection Plan Data File'
      file_filter             '*.txt'
      multiselection          abap_false
    CHANGING
      file_table              lt_filetable
      rc                      lf_rc
    EXCEPTIONS
      file_open_dialog_failed 1
      cntl_error              2
      error_no_gui            3
      not_supported_by_gui    4
      OTHERS                  5.



  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

               DISPLAY LIKE 'E'

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    EXIT.

  ENDIF.



* Number of selected filed must be equal to one.

  CHECK lf_rc 1.



* Access selected file

  DATA:

    ls_file TYPE file_table.



  READ TABLE lt_filetable INTO ls_file INDEX 1.



  CHECK sy-subrc 0.



  v_file ls_file-filename.



  SPLIT v_file AT '.' INTO p_file v_fext.

* Check if Text file is Selected

  IF v_fext NE 'txt'.

    MESSAGE 'Invalid File Type !' TYPE 'I'.

    SUBMIT z6qm011c_insp_plan_upl_n.

  ENDIF.

ENDFORM.                    " CHOOSE_DATA_FILE



*&------------------------------------------------------------------*

*&      Form  LOAD_DATA_FROM_FILE

*&------------------------------------------------------------------*

* Subroutine to Load data into Internal table from text file

*-------------------------------------------------------------------*

FORM load_data_from_file .
* Call Function module to load data from Text File
  CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      filename                v_file
      filetype                'DAT'
    TABLES
      data_tab                it_insplan
    EXCEPTIONS
      conversion_error        1
      file_open_error         2
      file_read_error         3
      invalid_type            4
      no_batch                5
      unknown_error           6
      invalid_table_width     7
      gui_refuse_filetransfer 8
      customer_error          9
      no_authority            10
      OTHERS                  11.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  LOOP AT it_insplan.
    it_insplan-material |{ it_insplan-material  ALPHA IN }|.
    MODIFY it_insplan.
  ENDLOOP.


ENDFORM.                    " LOAD_DATA_FROM_FILE
*&----------------------------------------------------------------*
*&      Form  CALL_BAPI_AND_COMMIT
*&----------------------------------------------------------------*
* Subroutine to Load the inspection plans
*----------------------------------------------------------------*
FORM call_bapi_and_commit .
* Initialise internal table
  REFRESH t_return.
  DELETE ADJACENT DUPLICATES FROM t_materialtaskallocation
   COMPARING ALL FIELDS.
* Call Function to Create Inspection Plan
  CALL FUNCTION 'BAPI_INSPECTIONPLAN_CREATE'
    IMPORTING
      group                  v_group
      groupcounter           v_grpcounter
    TABLES
      task                   t_task
      materialtaskallocation t_materialtaskallocation
      operation              t_operation
      inspcharacteristic     t_inspcharacteristic
      textallocation         t_textheader
      text                   t_textdata
      return                 t_return.

  READ TABLE t_return INDEX 1.
  DESCRIBE TABLE t_return.

* Check for success message and then Commit, otherwise dont commit
  IF t_return-type EQ 'S' AND sy-tfill EQ 1.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* Populate Success message in internal table for ALV Log display
    it_loghead-plant v_plant.
    it_loghead-material t_materialtaskallocation-material.
    it_loghead-msgtype 'S'.
    it_loghead-msg 'Inspection Plan Created Successfully'.
    APPEND it_loghead.
  ELSE.
* Populate Error message in internal table for ALV Log display
    it_loghead-plant v_plant.
    it_loghead-material t_materialtaskallocation-material.
    it_loghead-msgtype 'E'.
    it_loghead-msg 'Inspection Plan Not Created'.
    APPEND it_loghead.

* Retrieve and populate Error Details for Log Display
    CLEAR t_return.

    LOOP AT t_return.
      it_logdetail-plant v_plant.
      it_logdetail-material t_materialtaskallocation-material.
      it_logdetail-msgtype t_return-type.
      it_logdetail-msg t_return-message.
      IF t_return-parameter IS NOT INITIAL.
        CONCATENATE it_logdetail-msg '- Error in parameter'
        t_return-parameter INTO it_logdetail-msg SEPARATED BY space.
        IF t_return-row IS NOT INITIAL.
          v_row t_return-row.
          CONCATENATE it_logdetail-msg '- In Row' v_row
          INTO it_logdetail-msg SEPARATED BY space.
        ENDIF.
      ENDIF.
      APPEND it_logdetail.
    ENDLOOP.
    REFRESH t_return.
  ENDIF.
ENDFORM.                    " CALL_BAPI_AND_COMMIT
*&---------------------------------------------------------------------*
*&      Form  CLEAR_INTERNAL_TABLES
*&---------------------------------------------------------------------*
* Subroutine to Clear Internal Tables
*----------------------------------------------------------------------*
FORM clear_internal_tables .
  CLEARt_materialtaskallocation[]t_task[]t_operation[],
  t_textheader[]t_textdata[]t_inspcharacteristic[]t_return[].
ENDFORM.                    " CLEAR_INTERNAL_TABLES
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_LOG_LIST
*&---------------------------------------------------------------------*
* Subroutine to Display Log
*-------------------------------------------------------------------*
FORM display_log_list .
  DATAit_fieldcat TYPE slis_t_fieldcat_alv,
        wa_fieldcat TYPE LINE OF slis_t_fieldcat_alv,
        wa_layout   TYPE slis_layout_alv,
        it_keyinfo  TYPE TABLE OF slis_keyinfo_alv WITH HEADER LINE.

* Create FieldCatalog for ALV
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         sy-repid
      i_internal_tabname     'IT_LOGHEAD'
      i_inclname             sy-repid
    CHANGING
      ct_fieldcat            it_fieldcat[]
    EXCEPTIONS
      inconsistent_interface 1
      program_error          2
      OTHERS                 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         sy-repid
      i_internal_tabname     'IT_LOGDETAIL'
      i_inclname             sy-repid
    CHANGING
      ct_fieldcat            it_fieldcat[]
    EXCEPTIONS
      inconsistent_interface 1
      program_error          2
      OTHERS                 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  LOOP AT it_fieldcat INTO wa_fieldcat WHERE fieldname 'MSG'.
    wa_fieldcat-seltext_l 'Message'.
    wa_fieldcat-seltext_m 'Message'.
    wa_fieldcat-seltext_s 'Message'.
    MODIFY it_fieldcat FROM wa_fieldcat.
  ENDLOOP.

  it_keyinfo-header01 'PLANT'.
  it_keyinfo-header02 'MATERIAL'.
  it_keyinfo-item01 'PLANT'.
  it_keyinfo-item02 'MATERIAL'.
  APPEND it_keyinfo.

  wa_layout-expand_fieldname 'EXPAND'.
  wa_layout-def_status ' '.

  SORT it_logdetail BY plant material msg.
  DELETE ADJACENT DUPLICATES FROM it_logdetail COMPARING plant material msg.

* Call function to display ALV LOG
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
      i_callback_program    sy-repid
      it_fieldcat           it_fieldcat
      is_layout             wa_layout
      i_default             'X'
      i_save                'A'
      i_tabname_header      'IT_LOGHEAD'
      i_tabname_item        'IT_LOGDETAIL'
      is_keyinfo            it_keyinfo
      i_bypassing_buffer    'X'
      i_suppress_empty_data abap_true
    TABLES
      t_outtab_header       it_loghead
      t_outtab_item         it_logdetail
    EXCEPTIONS
      program_error         1
      OTHERS                2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " DISPLAY_LOG_LIST
*&---------------------------------------------------------------------*
*&      Form  Display_Progress_timer
*&---------------------------------------------------------------------*
* Subroutine to show Progress at Status Bar
*----------------------------------------------------------------------*
FORM display_progress_timer .
  v_per sy-tabix / v_lines * 100.
  WRITE v_per TO v_txt.
  CONDENSE v_txt.

  CONCATENATE v_txt '% of Inspection Plans Completed'
   INTO v_txt SEPARATED BY space.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      percentage v_per
      text       v_txt.

ENDFORM.                    "display_progress_timer
*&---------------------------------------------------------------------*
*&      Form  F_FILL_INFOTEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_fill_infotext .
  MOVE'X' TO g_lines_tab-hell,
        'X' TO g_lines_tab-topofpage,
        'Format for Upload Data'(005)  TO g_lines_tab-text.
  APPEND g_lines_tab.

  MOVE:  'X' TO g_lines_tab-hell,
          ' ' TO g_lines_tab-topofpage,
          'Field        Type      Width  Dec  Remarks'(006)
          TO g_lines_tab-text.
  APPEND g_lines_tab.
  MOVE ' ' TO g_lines_tab-text.
  APPEND g_lines_tab.

  PERFORM append_fields USING:
'WERKS' 'Char' '4' '' 'Plant',
'MATNR' 'Char' '18' '' 'Material',
'KTEXT' 'Char' '40' '' 'Task List Desc',
'VERWE' 'Char' '3' '' 'Task List Usage',
'STATU' 'Char' '3' '' 'Status',

'LOSVN' 'Char' '13' '' 'From Lot Size',
'LOSBS' 'Char' '13' '' 'To Lot Size',
'KAP_ARBPL' 'Char' '8' '' 'Planning WOrk Center',
'STTAG' 'Char' '10' '' 'Key Date DD.MM.YYYY ',
'PLNAL' 'Numc' '2' ' ' 'Group counter',
'STEUS' 'Char' '4' '' 'Control key',

'VERWMERKM' 'Char' '8' '' 'Master Inspection Characteristics',
'MKVERSION' 'Char' '6' '' 'Version Number',
'TXLINE' 'Char' '72' '' 'Text Line',
'TXLINE1' 'Char' '72' '' 'Text Line1',
'TXLINE2' 'Char' '72' '' 'Text Line2',
'TXLINE3' 'Char' '72' '' 'Text Line3',
'TXLINE4' 'Char' '72' '' 'Text Line4',

'TOLERUNTEN'  'Char'  '1'  ''  'Lower Specification Limit',
'TOLEROBEN'  'Char'  '1'  ''  'Upper Specification Limit',
'STICHPR' 'Char' '1' '' 'Sampling Procedure Required',
'LZEITKZ' 'Char' '1' '' 'Long-Term Inspection',
'STICHPRVER' 'Char' '8' '' 'Sampling Procedure ',

'STELLEN' 'Char' '2' '' 'No of Places',
'MASSEINHSW'  'Char'  '6'  ''  'Measurement Unit',
'TOLERANZUN' 'Char' '16' '' 'Lower Specification Limit',
'TOLERANZOB' 'Char' '16' '' 'Upper Specification Limit',
'SEL_SET1' 'Char' '8' '' 'Assigned Code Group',
'PSEL_SET1' 'Char' '4' '' 'Plant of Selected Set'.

ENDFORM.                    " F_FILL_INFOTEXT
*&---------------------------------------------------------------------*
*&      Form  APPEND_FIELDS
*&---------------------------------------------------------------------*
FORM append_fields USING field typ width decm rem.
  DATA text(140).
  text field.
  text+13(10)  typ.
  text+24(6)  width.
  text+30(5)  decm.
  text+35(80)  rem.

  MOVE:  ' ' TO g_lines_tab-hell,
         ' ' TO g_lines_tab-topofpage,
        text TO g_lines_tab-text.
  APPEND g_lines_tab.
ENDFORM.                    " APPEND_FIELDS