Michael's profileAt world's endBlogGuestbookNetwork Tools Help

Blog


    October 29

    SAP用户密码加密函数

    REPORT  z_barry_user_pass.
    TABLES: usr02,xu400 .

    DATA: msgid LIKE sy-msgid,
          msgno LIKE sy-msgno,
          param.
         
    usr02-bname = 'BARRY'.
    xu400-newcode = 'BARRY'.

    CALL 'XXPASS'
      ID 'CODE' FIELD xu400-newcode
      ID 'CODX' FIELD usr02-bcode
      ID 'NAME' FIELD usr02-bname  
      ID 'VERS' FIELD usr02-codvn  
      ID 'MESG' FIELD msgno
      ID 'ARBG' FIELD msgid.

    WRITE usr02-bcode .

    友情提示:运行CALL 'XXPASS'前最好跟Basis搞好关系,在你运行后好让他给你解除用户锁定,哈哈

    利用Excel显示数据

    REPORT  zrs08056        .

    TABLES: t001,dd02l.
    DATA: zx030l LIKE x030l.
    DATA BEGIN OF zdfies OCCURS 0.
            INCLUDE STRUCTURE dfies.
    DATA END OF zdfies.
    DATA: BEGIN OF flditab OCCURS 0,
          fldname(11) TYPE c,
          END OF flditab.
    DATA itabt001 LIKE t001 OCCURS 0 WITH HEADER LINE.
    DATA tname LIKE dd02l-tabname.

    START-OF-SELECTION.
      SELECT * FROM t001 INTO TABLE itabt001.
      tname = 'T001'.
      PERFORM getfieleds.
      PERFORM showdata.

    *&---------------------------------------------------------------------*
    *&      Form  GETFIELEDS
    *&---------------------------------------------------------------------*
    FORM getfieleds.
      CALL FUNCTION 'GET_FIELDTAB'
        EXPORTING
          langu               = sy-langu
          only                = space
          tabname             = tname
          withtext            = 'X'
        IMPORTING
          header              = zx030l
        TABLES
          fieldtab            = zdfies
        EXCEPTIONS
          internal_error      = 01
          no_texts_found      = 02
          table_has_no_fields = 03
          table_not_activ     = 04.
      CASE sy-subrc.
        WHEN 0.
          LOOP AT zdfies.
            flditab-fldname = zdfies-fieldname.
            APPEND flditab.
          ENDLOOP.
        WHEN OTHERS.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH  sy-subrc.
      ENDCASE.
    ENDFORM.                    "GETFIELEDS

    *&---------------------------------------------------------------------*
    *&      Form  SHOWdata
    *&---------------------------------------------------------------------*
    FORM showdata.
      CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          file_name                 = 'C:\T001.XLS'
          data_sheet_name           = 'USER LIST'
        TABLES
          data_tab                  = itabt001
          fieldnames                = flditab
        EXCEPTIONS
          file_not_exist            = 1
          filename_expected         = 2
          communication_error       = 3
          ole_object_method_error   = 4
          ole_object_property_error = 5
          invalid_filename          = 6
          invalid_pivot_fields      = 7
          download_problem          = 8
          OTHERS                    = 9.
      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.           

    通过RFC把本系统程序放入另外一个系统执行并返回结果

    *&---------------------------------------------------------------------*
    *& Report                                                              *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&  通过RFC把本系统程序放入另外一个系统执行并返回结果                  *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    REPORT  z_barry_insert_abap             .
     
    DATA : itab_prog(140) OCCURS 0 WITH HEADER LINE.
    DATA : itab_ret(1023) OCCURS 0 WITH HEADER LINE.
    DATA : err_msg LIKE sy-msgv1.
     
    PARAMETER p_report LIKE sy-repid MEMORY ID rid.
    PARAMETER p_rfcdes LIKE rfcdes-rfcdest.
     
    START-OF-SELECTION.
      REFRESH : itab_prog , itab_ret.
      READ REPORT p_report INTO itab_prog.
      CALL FUNCTION 'RFC_ABAP_INSTALL_AND_RUN' DESTINATION p_rfcdes
        EXPORTING
          mode         = 'F'
        IMPORTING
          errormessage = err_msg
        TABLES
          program      = itab_prog
          writes       = itab_ret
        EXCEPTIONS
          OTHERS       = 1.
      IF sy-subrc <> 0.
        MESSAGE e000(z900) WITH err_msg. WRITE :/ err_msg.
      ELSE.
        IF NOT itab_ret[] IS INITIAL.
          LOOP AT itab_ret.
            WRITE :/ itab_ret.
          ENDLOOP.
        ENDIF.
      ENDIF.
     
    注:因此函数为RFC函数,可以利用第三方软件做远程程序执行,如Excel。但需要注意的是,如果目标Client设置为不允许修改(SCC4),则会返回错误

    用 HTML 输出 LIST 报表

    *&---------------------------------------------------------------------*
    *& Report  ZRS08186                                                    *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *& 用 HTML 输出 LIST 报表                                                *
    *& Submit一个程序,然后把结果保存为HTML文件                                *
    *&---------------------------------------------------------------------*
    REPORT  z_barry_html_out   LINE-SIZE 450     .
    DATA: mtab_report_list LIKE abaplist OCCURS 0 WITH HEADER LINE,
          mtab_report_html LIKE w3html OCCURS 0 WITH HEADER LINE.
    PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY DEFAULT 'C:\testhtm.htm' ,
                p_sname(128) DEFAULT '/usr/sap/DEV/DVEBMGS00/work/TESThtml.htm' LOWER CASE NO-DISPLAY .
    SUBMIT z_barry_html_out_alv EXPORTING LIST TO MEMORY AND RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = mtab_report_list
      EXCEPTIONS
        not_found  = 1.
    CALL FUNCTION 'WRITE_LIST'
      TABLES
        listobject = mtab_report_list
      EXCEPTIONS
        empty_list = 1
        OTHERS     = 2.
    *CALL FUNCTION 'WWW_LIST_TO_HTML'
    *  TABLES
    *    html = mtab_report_html.
    CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
      TABLES
        html       = mtab_report_html
        listobject = mtab_report_list.
    IF sy-subrc NE 0.
      WRITE: / 'ERROR IN GENERATING THE HTML FORMAT'.
      EXIT.
    ENDIF.
    *CALL FUNCTION 'WS_DOWNLOAD'
    *  EXPORTING
    *    filename = p_fname
    *    mode     = 'BIN'
    *  TABLES
    *    data_tab = mtab_report_html
    *  EXCEPTIONS
    *    OTHERS   = 1.
    *
    *IF sy-subrc <> 0.
    *  WRITE:/ 'ERROR DOWNLOADING', p_fname.
    *ELSE.
    *  WRITE: / 'OUTPUT SAVED IN FILE', p_fname.
    *ENDIF.
    OPEN DATASET p_sname FOR OUTPUT IN BINARY MODE.
    LOOP AT mtab_report_html.
      TRANSFER mtab_report_html TO p_sname.
    ENDLOOP.
    CLOSE DATASET p_sname.
    PERFORM down_file USING p_sname p_fname .
    IF sy-subrc <> 0.
      WRITE:/ 'ERROR DOWNLOADING', p_fname.
    ELSE.
      WRITE: / 'OUTPUT SAVED IN FILE', p_fname.
    ENDIF.
    *&--------------------------------------------------------------------*
    *&      Form  down_file
    *&--------------------------------------------------------------------*
    FORM down_file USING    p_path file_name .
      DATA: path LIKE rcgfiletr-ftappl .
      DATA: localfile LIKE rcgfiletr-ftfront.
      path = p_path .
      localfile = file_name .
      CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
        EXPORTING
          i_file_front_end    = localfile
          i_file_appl         = path
          i_file_overwrite    = 'X'
        EXCEPTIONS
          fe_file_open_error  = 1
          fe_file_exists      = 2
          fe_file_write_error = 3
          ap_no_authority     = 4
          ap_file_open_error  = 5
          ap_file_empty       = 6
          OTHERS              = 7.
      IF sy-subrc <> 0.
        IF sy-msgty = '' .
          sy-msgty = 'E' .
        ENDIF .
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " DOWN_FILE

    ME21N/VA01的行项目回车后检查出口

    ME21N的行项目回车后检查出口
    MM06E005 --> EXIT_SAPMM06E_017 (PAI)
     
    IF sy-uname = 'BERRY'.
      DATA: tmpafnam LIKE ekpo-afnam,
            tmpmatnr LIKE mara-matnr,
            tmpxchpf LIKE marc-xchpf.
     
      SELECT SINGLE xchpf INTO tmpxchpf FROM marc
      WHERE werks = i_ekpo-werks AND
            matnr = i_ekpo-matnr .
      IF tmpxchpf = 'X'.
        IF i_ekpo-afnam = ''.
          MESSAGE w000(z900) WITH '请填写色号' INTO gl_dummy.
          mmpur_message 'W' 'Z900' '000' '请填写色号' '' '' ''.
        ENDIF.
      ENDIF.
    ENDIF.
     
     
    附:VA01 行项目回车后检查出口:
     
    MV45AFZZ 
    FORM userexit_move_field_to_vbap.

    Chart

    *&---------------------------------------------------------------------*
    *& Report  Z_BARRY_CHART                                               *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&   SAP Chart,如果需要Excel方式的图表,可以使用DOI、OLE                   *
    *&                                                                     *
    *&---------------------------------------------------------------------*

    REPORT  Z_BARRY_CHART                           .

    DATA: BEGIN OF itab_data OCCURS 0,
            dataname(15),
            quantity1 TYPE i,
            quantity2 TYPE i,
            quantity3 TYPE i,
            quantity4 TYPE i,
    END OF itab_data,

    BEGIN OF itab_options OCCURS 0,
            option(20),
    END OF itab_options.

    itab_data-dataname = '电'.
    itab_data-quantity1 = 55.
    itab_data-quantity2 = 62.
    itab_data-quantity3 = 59.
    APPEND itab_data.

    itab_data-dataname = '气'.
    itab_data-quantity1 = 35.
    itab_data-quantity2 = 52.
    itab_data-quantity3 = 44.
    APPEND itab_data.

    itab_data-dataname = '水'.
    itab_data-quantity1 = 18.
    itab_data-quantity2 = 22.
    itab_data-quantity3 = 19.
    APPEND itab_data.

    itab_data-dataname = '米'.
    itab_data-quantity1 = 8.
    itab_data-quantity2 = 22.
    itab_data-quantity3 = 9.
    itab_data-quantity4 = 19.
    APPEND itab_data.

    itab_options-option = 'P2TYPE = LN'.
    append itab_options.

    CALL FUNCTION 'GRAPH_MATRIX_3D'
      EXPORTING
        col1   = '一月份'
        col2   = '二月份'
        col3   = '三月份'
        col4   = '四月份'
        titl   = '水电气使用情况'
      TABLES
        data   = itab_data
        opts   = itab_options
      EXCEPTIONS
        OTHERS = 1.

    Mail-地文件做为附件发送

    *&---------------------------------------------------------------------*
    *& Report  ZRS08094                                                    *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&     mail 本地文件做为附件发送                                       *
    *&                                                                     *
    *&---------------------------------------------------------------------*

    REPORT  zrs08094                                                    .


    DATA method1 LIKE sy-ucomm.
    DATA g_user LIKE soudnamei1.
    DATA g_user_data LIKE soudatai1.
    DATA g_owner LIKE soud-usrnam.
    DATA g_receipients LIKE soos1 OCCURS 0 WITH HEADER LINE.
    DATA g_document LIKE sood4 .
    DATA g_header LIKE sood2.
    DATA g_folmam LIKE sofm2.
    DATA g_objcnt LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA g_objhead LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA g_objpara  LIKE selc OCCURS 0 WITH HEADER LINE.
    DATA g_objparb  LIKE soop1 OCCURS 0 WITH HEADER LINE.
    DATA g_attachments LIKE sood5 OCCURS 0 WITH HEADER LINE.
    DATA g_references LIKE soxrl OCCURS 0 WITH HEADER LINE.

    DATA g_authority LIKE sofa-usracc.
    DATA g_ref_document LIKE sood4.
    DATA g_new_parent LIKE soodk.
    DATA: BEGIN OF g_files OCCURS 10 ,
            text(4096) TYPE c,
          END OF g_files.

    DATA : fold_number(12) TYPE c,
           fold_yr(2) TYPE c,
           fold_type(3) TYPE c.

    PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\AAA.txt'.

    g_user-sapname = sy-uname.

    CALL FUNCTION 'SO_USER_READ_API1'
      EXPORTING
        user            = g_user
      IMPORTING
        user_data       = g_user_data
      EXCEPTIONS
        user_not_exist  = 1
        parameter_error = 2
        x_error         = 3
        OTHERS          = 4.

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

    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    CLEAR g_files.

    REFRESH : g_objcnt,
              g_objhead,
              g_objpara,
              g_objparb,
              g_receipients,
              g_attachments,
              g_references,
              g_files.

    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.

    g_header-objdes =  '邮件标题'.
    g_header-file_ext = 'TXT'.

    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = method1
        office_user  = sy-uname
        ref_document = g_ref_document
        new_parent   = g_new_parent
      IMPORTING
        authority    = g_authority
      TABLES
        objcont      = g_objcnt
        objhead      = g_objhead
        objpara      = g_objpara
        objparb      = g_objparb
        recipients   = g_receipients
        attachments  = g_attachments
        references   = g_references
        files        = g_files
      CHANGING
        document     = g_document
        header_data  = g_header.

    * File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.

    g_files-text = ws_file.
    APPEND g_files.

    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = method1
        office_user  = g_owner
        ref_document = g_ref_document
        new_parent   = g_new_parent
      IMPORTING
        authority    = g_authority
      TABLES
        objcont      = g_objcnt
        objhead      = g_objhead
        objpara      = g_objpara
        objparb      = g_objparb
        recipients   = g_receipients
        attachments  = g_attachments
        references   = g_references
        files        = g_files
      CHANGING
        document     = g_document
        header_data  = g_header.


    *Send the mail..
    method1 = 'SEND'.

    g_receipients-recnam = 'BAITZ'.
    *g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    *g_receipients-att_fix ='X' .
    APPEND  g_receipients.

    *g_receipients-recnam = 'ZHENGLL'.
    **g_receipients-recesc = 'B'.
    *g_receipients-sndex = 'X'.
    *g_receipients-att_fix ='X' .
    *APPEND  g_receipients.

    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = method1
        office_user  = g_owner
        ref_document = g_ref_document
        new_parent   = g_new_parent
      IMPORTING
        authority    = g_authority
      TABLES
        objcont      = g_objcnt
        objhead      = g_objhead
        objpara      = g_objpara
        objparb      = g_objparb
        recipients   = g_receipients
        attachments  = g_attachments
        references   = g_references
        files        = g_files
      CHANGING
        document     = g_document
        header_data  = g_header.

    *write 'aa'.

    格式化的日期转为SAP内部日期

    REPORT z_barry_test_date_format .
     
    DATA: dat TYPE erdat,
          str(10) TYPE c,
          df .
     
    dat = '20070803'.
     
    WRITE dat TO str .
     
    SELECT SINGLE datfm INTO df FROM usr01 WHERE bname = sy-uname.
    CALL FUNCTION 'DATE_STRING_CONVERT'
         EXPORTING
              date_format = df
              date_string = str
         IMPORTING
              result_date = dat.
     
    WRITE dat  .

    Send job to email

    REPORT z_barry_job_list .

    TYPE-POOLS: slis.
    TABLES:p0105_af,btch2170.
    DATA: gd_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: sla TYPE slis_layout_alv ,
          ivariant LIKE disvariant,
          i_repid LIKE sy-repid ,
          i_excluding TYPE slis_t_extab.

    DATA: BEGIN OF in_wa  .
            INCLUDE STRUCTURE btcselect.
    DATA: END OF in_wa.

    DATA: BEGIN OF itab OCCURS 0 .
            INCLUDE STRUCTURE tbtcjob_bk.
    DATA: END OF itab.

    DATA:   it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            gd_cnt TYPE i,
            gd_sent_all(1) TYPE c,
            gd_doc_data LIKE sodocchgi1,
            gd_error TYPE sy-subrc.

    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    PARAMETERS : p_user LIKE btch2170-username OBLIGATORY DEFAULT sy-uname .
    SELECT-OPTIONS: s_date FOR btch2170-from_date NO-EXTENSION
                                                        DEFAULT sy-datum ,
                    s_addr FOR p0105_af-email DEFAULT 'BAITIANZHEN@163.COM'.

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS p_pre AS CHECKBOX DEFAULT 'X' .
    SELECTION-SCREEN COMMENT (10) text-001 FOR FIELD p_pre .
    PARAMETERS p_sch AS CHECKBOX DEFAULT 'X' .
    SELECTION-SCREEN COMMENT (10) text-002 FOR FIELD p_sch .
    PARAMETERS p_rea AS CHECKBOX  DEFAULT 'X'.
    SELECTION-SCREEN COMMENT (10) text-003 FOR FIELD p_rea .
    PARAMETERS p_run AS CHECKBOX  DEFAULT 'X'.
    SELECTION-SCREEN COMMENT (10) text-004 FOR FIELD p_run .
    PARAMETERS p_fin AS CHECKBOX  DEFAULT 'X'.
    SELECTION-SCREEN COMMENT (10) text-005 FOR FIELD p_fin .
    PARAMETERS p_abo AS CHECKBOX  DEFAULT 'X'.
    SELECTION-SCREEN COMMENT (10) text-006 FOR FIELD p_abo .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1.

    START-OF-SELECTION.
      PERFORM getdata.
      PERFORM outdata.
    *  PERFORM send_mail.

    *---------------------------------------------------------------------*
    *       FORM getdata                                                  *
    *---------------------------------------------------------------------*
    FORM getdata.
      in_wa-jobname = '*'.
      in_wa-username = p_user .
      in_wa-from_date = s_date-low.
      in_wa-to_date = s_date-high .

    ***Job的状态
      in_wa-prelim = p_pre.
      in_wa-schedul = p_sch.
      in_wa-ready = p_rea .
      in_wa-running = p_run.
      in_wa-finished = p_fin.
      in_wa-aborted = p_abo.

      CALL FUNCTION 'BP_JOB_SELECT_SM37B'
        EXPORTING
          jobselect_dialog          = 'N'
          jobsel_param_in           = in_wa
        TABLES
    *   JOBSELECT_JOBLIST         =
          jobselect_joblist_b       = itab
       EXCEPTIONS
         invalid_dialog_type       = 1
         jobname_missing           = 2
         no_jobs_found             = 3
         selection_canceled        = 4
         username_missing          = 5
         OTHERS                    = 6   .
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  outdata
    *&---------------------------------------------------------------------*
    FORM outdata.
      sla-colwidth_optimize = 'X'.
      sla-zebra             = 'X'.
      i_repid = sy-repid.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = i_repid
                i_structure_name   = 'TBTCJOB_BK'
                is_layout          = sla
           TABLES
                t_outtab           = itab
           EXCEPTIONS
                program_error      = 1
                OTHERS             = 2.
    ENDFORM.                    " outdata

    *---------------------------------------------------------------------*
    *       FORM send_email_message                                       *
    *---------------------------------------------------------------------*
    FORM send_mail.
      DATA: txt TYPE string .

      gd_doc_data-doc_size = 1.
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      CONCATENATE 'Job监控自动发送邮件' '' INTO gd_doc_data-obj_descr.
      gd_doc_data-sensitivty = 'F'.

      LOOP AT itab.
        CASE itab-status.
          WHEN 'P'.
            txt = 'PRELIMINARY'.
          WHEN 'S'.
            txt = 'SCHEDULED'.
          WHEN 'Y'.
            txt = 'READY'.
          WHEN 'R'.
            txt = 'RUNNING'.
          WHEN 'F'.
            txt = 'FINISHED'.
          WHEN 'A'.
            txt = 'ABORTED'.
        ENDCASE.

        CONCATENATE itab-jobname ',' txt INTO it_message .
        APPEND it_message.
      ENDLOOP.

      CLEAR it_packing_list.
      REFRESH it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      APPEND it_packing_list.

      CLEAR it_receivers.
      REFRESH it_receivers.
      LOOP AT s_addr.
        it_receivers-receiver = s_addr-low.
        it_receivers-rec_type = 'U'.
        it_receivers-com_type = 'INT'.
        it_receivers-notif_del = 'X'.
        it_receivers-notif_ndel = 'X'.
        APPEND it_receivers.
        CLEAR it_receivers.
      ENDLOOP.

      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           IMPORTING
                sent_to_all                = gd_sent_all
           TABLES
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.

      IF sy-subrc = 0 .
        WAIT UP TO 2 SECONDS.
        SUBMIT rsconn01 WITH mode = 'INT'
                      WITH output = 'X'
                      AND RETURN.
      ENDIF.
    ENDFORM.                    " SEND_EMAIL_MESSAGE

    ZCONVERT_SPOOL_2LOCAL_PDF.

    FUNCTION ZCONVERT_SPOOL_2LOCAL_PDF.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(SPOOLNO) TYPE  TSP01-RQIDENT
    *"     VALUE(P_FILE) TYPE  RLGRAP-FILENAME DEFAULT 'C:\FILE.PDF'
    *"----------------------------------------------------------------------
    *
    * External Ref : RSTXPDFT4
    *
    DATA download VALUE 'X'.
    DATA otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
    DATA cancel.
    DATA pdf LIKE tline OCCURS 100 WITH HEADER LINE.
    DATA doctab LIKE docs OCCURS 1 WITH HEADER LINE.
    DATA: numbytes TYPE i,
            arc_idx LIKE toa_dara,
            pdfspoolid LIKE tsp01-rqident,
            jobname LIKE tbtcjob-jobname,
            jobcount LIKE tbtcjob-jobcount,
            is_otf.
    DATA: client LIKE tst01-dclient,
            name LIKE tst01-dname,
            objtype LIKE rststype-type,
    type LIKE rststype-type.
    TABLES: tsp01.  SELECT SINGLE * FROM tsp01
    WHERE rqident = spoolno.  IF sy-subrc <> 0.
    MESSAGE e001(zmsd) WITH text-001.  " Fail
    EXIT.
    ENDIF.  client = tsp01-rqclient.
      name   = tsp01-rqo1name.
    CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
    EXPORTING
                authority     = 'SP01'
    client        = client
                name          = name
                part          = 1
    IMPORTING
    type          = type
                objtype       = objtype
    EXCEPTIONS
                fb_error      = 1
                fb_rsts_other = 2
                no_object     = 3
                no_permission = 4.
    IF objtype(3) = 'OTF'.
        is_otf = 'X'.
    ELSE.
        is_otf = space.
    ENDIF.  IF is_otf = 'X'.
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
                  src_spoolid              = spoolno
                  no_dialog                = ' '
    IMPORTING
                  pdf_bytecount            = numbytes
                  pdf_spoolid              = pdfspoolid
                  btc_jobname              = jobname
                  btc_jobcount             = jobcount
    TABLES
                  pdf                      = pdf
    EXCEPTIONS
                  err_no_otf_spooljob      = 1
                  err_no_spooljob          = 2
                  err_no_permission        = 3
                  err_conv_not_possible    = 4
                  err_bad_dstdevice        = 5
                  user_cancelled           = 6
                  err_spoolerror           = 7
                  err_temseerror           = 8
                  err_btcjob_open_failed   = 9
                  err_btcjob_submit_failed = 10
                  err_btcjob_close_failed  = 11.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e001(zmsd) WITH text-002.
    "CONVERT_OTFSPOOLJOB_2_PDF Fail
    EXIT.
    ENDCASE.
    ELSE.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
                  src_spoolid              = spoolno
                  no_dialog                = ' '
    IMPORTING
                  pdf_bytecount            = numbytes
                  pdf_spoolid              = pdfspoolid
                  btc_jobname              = jobname
                  btc_jobcount             = jobcount
    TABLES
                  pdf                      = pdf
    EXCEPTIONS
                  err_no_abap_spooljob     = 1
                  err_no_spooljob          = 2
                  err_no_permission        = 3
                  err_conv_not_possible    = 4
                  err_bad_destdevice       = 5
                  user_cancelled           = 6
                  err_spoolerror           = 7
                  err_temseerror           = 8
                  err_btcjob_open_failed   = 9
                  err_btcjob_submit_failed = 10
                  err_btcjob_close_failed  = 11.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE e001(zmsd) WITH text-003.
    "CONVERT_ABAPSPOOLJOB_2_PDF Fail
    EXIT.
    ENDCASE.
    ENDIF.
    *************** download PDF file ***********
    CHECK download = 'X'.
    IF NOT ( jobname IS INITIAL ).
    EXIT.
    ENDIF.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
                filename            = p_file
                filetype            = 'BIN'
                bin_filesize        = numbytes
    TABLES
                data_tab            = pdf
    EXCEPTIONS
                file_open_error     = 1
                file_write_error    = 2
                invalid_filesize    = 3
                invalid_table_width = 4
                invalid_type        = 5
                no_batch            = 6
                unknown_error       = 7
    OTHERS              = 8.  IF sy-subrc <> 0.
    MESSAGE 'Download local file fail!' type 'E' DISPLAY LIKE 'E'.    "Fail
    ENDIF.
    ENDFUNCTION.

    October 27

    SAP中如何控制某个report一次只能打印一份

    SAP中如何控制某个report一次只能打印一份
    2008年06月17日 星期二 15:42

    呵呵, 这个要求是不是有点变态? 公司的要求总是多样的,偶们只有让客户满意.
    公司的一个搬出报表,一次只准打印一份, 但如何控制。和DEVELOPER研究了将近5个小时,终于搞定。
    Step1:
        运行该报表-> 点击系统打印按钮 -> 光标放到 Number of copies -> F1 -> 点击 "Technical info"
        -> 找到 'Program name: SAPLSPRI','Screen number: 0100','Data element: SYPRCOP'
    Step2:
         Create a new session -> T-code: cmod ->Goto -> Text enhancements -> Field exits
    Step3:
         在Step2 中画面的菜单 "Field exits" -> Create -> Data element输入 SYPRCOP -> 点击"Continue"
        ->Fld. Exit 输入 1(表示version), Program 输入"SAPLSPRI", Screen输入"0100" ->系统自动生成
        Function module "FIELD_EXIT_SYPRCOP_1"
    Step4:
         编辑Function Module 函数如下(手动添加代码):
         FUNCTION FIELD_EXIT_SYPRCOP_1.
         *以下注释的代码为系统自动生成
         *"----------------------------------------------------------------------
         *"*"Local interface:
         *" IMPORTING
         *"     REFERENCE(INPUT)
         *" EXPORTING
         *"     REFERENCE(OUTPUT)
         *"----------------------------------------------------------------------
         *以下代码为手动添加,在Table zf002中控制一次只能打印一份的report
         data: value1 like SY-pRCOP,
            numcopy(3) type n,
            $copy type i.
         value1 = input.
         utput = value1.
         if value1 gt 1.
         select single * from zf002 where ZZCD_TYPE eq 'BC03'
                                     and ZZCD_KEY eq sy-cprog.
         if sy-subrc eq 0.
          numcopy = zf002-ZZBIG_CODE.
          $copy = numcopy.
          if value1 gt numcopy.
           message e001(zg) with 'This report can be printed only'
                                  $copy 'copys !'.
        *        message e001(zg) with 'You can only Print' $copy 'copys !'.
          endif.
         endif.
         endif.
    ENDFUNCTION.

    转载:http://space.itpub.net/13316/viewspace-310329

    PP Transaction

    AP PP Report
    2009-08-28 20:31

    1、MRP清单显示与分析
    MD05 MRP清单
    MD06 MRP清单 -
    MDLD 打印MRP清
    MD04 库存/需求
    MD07 库存/需求
    MD45 计划结果
    MD46 计划结果集
    MD44 计划情形-
    MD47 计划编制情
    MD48 计划编制情
    MD4C 订单报表
    CO46 订单进程
    MD09 溯源需求

    2、物料BOM显示
    CS11 逐层BOM
    CS12 逐层 BOM
    CS13 汇总 BOM

    3、订单BOM显示
    CSK1 逐层BOM
    CSK2 多层 BOM
    CSK3 汇总 BOM

    4、BOM使用处清单显示
    CS15 物料
    CSD5 凭证(单级)
    CSC5 类(单级)

    5、工作中心信息系统
    CR60 工作中心信息系统
    CR05 工作中心清单
    CR06 成本中心分配
    CR07 工作中心能力
    CR08 工作中心层次

    6、工艺路线显示
    CA80 工作中心
    CA90 参考工序集
    CA70 生产资源/工具
    CA03 工艺路线显示

    7、订单进程
    CO24 短缺部件信息系统
    CO46 订单进程
    MD08 重新组织MRP清单
    CO24 短缺部件信息系
    MD09 溯源需求
    能力评估报表
    MD04 库存/需求清单

    8、订单信息系统分析
    CO09 可用性总览
    MC01 使用信息集

    9、车间信息系统分析
    MCP7 工作中心
    MCP1 工序
    MCP5 物料
    MCP3 生产订单
    MCRE 物料消耗
    MCRI 产品成本

    10、生产成本差异分析
    S_ALR_87013139 累计的
    S_ALR_87013140 周期
    S_ALR_87013142 累计
    S_ALR_87013143 周期
    S_ALR_87013145 累计
    S_ALR_87013146 周期

    11、在制品分析
    S_ALR_87013151 实际/WIP: 累积
    S_ALR_87013152 实际/在制品: 定期

    12、计划成本分析
    S_ALR_87013154 累计
    S_ALR_87013155 周期

    13、按销售订单分析产品成本
    S_ALR_87013104 选择销售订单
    CKAPP03 显示要核算成本的销售
    S_P99_41000018 订单选择
    S_ALR_87013162 汇总层次概览
    KKAC 用于已分配订单的销
    KKBC_KUN 用于销售订单
    CK87_99 成本核算过的多层物料清单
    S_ALR_87013113 成本组件
    CK85_99_COST_ELEMENT 成本要素
    CK85_99 分条列举

    October 26

    Get Sales document Outstanding Func3

    FUNCTION ZGET_SO_OUTSTD.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_BUKRS) TYPE  BSID-BUKRS
    *"     VALUE(I_KUNNR) TYPE  VBAK-KUNNR OPTIONAL
    *"     VALUE(I_MATNR) TYPE  MARA-MATNR
    *"     VALUE(I_AUART) TYPE  VBAK-AUART
    *"  TABLES
    *"      OUT_VBEP STRUCTURE  ZVBEP
    *"  EXCEPTIONS
    *"      NO_FOUND
    *"----------------------------------------------------------------------
    TABLES:
          vbrk,vbrp,lips.
    DATA: l_index LIKE sy-tabix.
    DATA: BEGIN OF  it_vbep OCCURS 0.
    INCLUDE STRUCTURE Zvbep.
    DATA: UEPOS like VBAP-UEPOS. "Heigh LEVEL
    *DATA:   KWMENG  LIKE VBAP-KWMENG,
    *        NETWR   LIKE VBAP-NETWR,
    *        NETPR   LIKE VBAP-NETPR,
    *        KPEIN   LIKE VBAP-KPEIN.
    *DATA:   auart   LIKE vbak-auart.
    *DATA:   blmng   LIKE vbep-bmeng. "Confirmed Qty
    *DATA:   osmng   LIKE vbep-bmeng. "O/s Qty
    *DATA:   matnr   LIKE vbap-matnr.
    *DATA:   DMBSH   LIKE VBAP-NETWR.
    *DATA:   WAERK   LIKE VBAP-WAERK.
    DATA:   END OF  it_vbep.
    data: lt_vbep like it_vbep OCCURS 0 WITH HEADER LINE.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE it_vbep
    FROM vbak AS a
         INNER JOIN vbap AS b
    ON a~vbeln = b~vbeln
         INNER JOIN vbep AS c
    ON b~vbeln = c~vbeln
    AND b~posnr = c~posnr
    WHERE a~vkorg = I_BUKRS
    and b~matnr = I_MATNR
    AND c~bmeng > 0
    AND c~ettyp = 'CP'
    AND c~lfrel = 'X'.
    if not it_vbep[] is INITIAL.
    Loop at it_vbep.
    READ TABLE lt_vbep with key vbeln = it_vbep-vbeln
                                       posnr = it_vbep-posnr
                                       matnr = it_vbep-matnr.
    if sy-subrc eq 0.
             lt_vbep-WMENG = lt_vbep-WMENG + it_vbep-WMENG.
             lt_vbep-BMENG = lt_vbep-BMENG + it_vbep-BMENG.
    modify lt_vbep index sy-tabix.
    else.
    MOVE-CORRESPONDING it_vbep to lt_vbep.
    if it_vbep-uepos <= 0.
            lt_vbep-uepos = it_vbep-posnr.
    endif.
    append lt_vbep.
    endif.
    ENDloop.
    endif.
    it_vbep[] = lt_vbep[].
    clear it_vbep.
    LOOP AT it_vbep.
        l_index = sy-tabix.
    IF it_vbep-auart EQ  I_auart.
    PERFORM cal_delivery_qty  USING it_vbep-vbeln
                                          it_vbep-posnr
                                          it_vbep-vrkme
                                          it_vbep-matnr
    CHANGING it_vbep-blmng.
         it_vbep-osmng = it_vbep-bmeng - it_vbep-blmng.
         it_vbep-DMBSH = ( it_vbep-bmeng - it_vbep-blmng ) * it_vbep-NETPR  / it_vbep-kpein.
    ELSE.
    PERFORM get_inv_qty USING it_vbep-vbeln
                                    it_vbep-posnr
                                    it_vbep-matnr
    CHANGING it_vbep-blmng.
          it_vbep-osmng = it_vbep-bmeng - it_vbep-blmng.
          it_vbep-DMBSH = ( it_vbep-bmeng - it_vbep-blmng ) * it_vbep-NETPR  / it_vbep-kpein.
    ENDIF.
    modify it_VBEP index l_index.
    ENDLOOP.
       OUT_VBEP[] = IT_VBEP[].
    ENDFUNCTION.
    *&---------------------------------------------------------------------*
    *&      Form  CAL_DELIVERY_QTY
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->RVBELN     text
    *      -->RPOSNR     text
    *      -->RVRKME     text
    *      -->ZMATNR     text
    *      -->RLFIMG     text
    *----------------------------------------------------------------------*
    FORM cal_delivery_qty USING rvbeln rposnr rvrkme zmatnr CHANGING rlfimg.
    DATA: zlfart LIKE likp-lfart.
      rlfimg = 0.
    SELECT *
    FROM   lips CLIENT SPECIFIED
    WHERE  mandt EQ sy-mandt AND vgbel EQ rvbeln AND vgpos EQ rposnr AND matnr = zmatnr.
    SELECT SINGLE lfart INTO zlfart
    FROM   likp CLIENT SPECIFIED
    WHERE  mandt EQ sy-mandt AND vbeln EQ lips-vbeln AND lfart EQ 'LF'.
    IF sy-subrc EQ 0.
    IF lips-vrkme EQ rvrkme.
            rlfimg = rlfimg + lips-lfimg.
    ELSE.
            rlfimg = rlfimg + ( lips-lfimg * lips-umvkz / lips-umvkn ).
    ENDIF.
    ENDIF.
    ENDSELECT.
    ENDFORM.                    "cal_delivery_qty
    *&---------------------------------------------------------------------*
    *&      Form  GET_INV_QTY
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->ZAUBEL     text
    *      -->ZAUPOS     text
    *      -->ZMATNR     text
    *      -->ZFKIMG     text
    *----------------------------------------------------------------------*
    FORM get_inv_qty USING zaubel zaupos zmatnr CHANGING zfkimg.
      zfkimg = 0.
    SELECT * FROM vbrp CLIENT SPECIFIED
    WHERE mandt EQ sy-mandt
    AND aubel EQ zaubel
    AND aupos EQ zaupos
    AND matnr EQ zmatnr
    AND shkzg NE 'X'. "Return item.
    SELECT SINGLE * FROM vbap CLIENT SPECIFIED
    WHERE mandt EQ sy-mandt
    AND vbeln EQ vbrp-aubel
    AND posnr EQ vbrp-aupos
    AND matnr EQ zmatnr.
    SELECT SINGLE * FROM vbrk CLIENT SPECIFIED
    WHERE mandt EQ sy-mandt
    AND vbeln EQ vbrp-vbeln
    AND fksto NE 'X'. "Cancelled INV.
    IF vbrk-fkart EQ 'F2' OR vbrk-fkart EQ 'ZF2'.
    IF vbrp-vrkme EQ vbap-vrkme.
            zfkimg = zfkimg + vbrp-fkimg.
    ELSE.
            zfkimg = zfkimg + ( vbrp-fkimg * vbrp-umvkz / vbrp-umvkn ).
    ENDIF.
    ELSEIF vbrk-fkart EQ 'S1'.
    IF vbrp-vrkme EQ vbap-vrkme.
            zfkimg = zfkimg - vbrp-fkimg.
    ELSE.
            zfkimg = zfkimg - ( vbrp-fkimg * vbrp-umvkz / vbrp-umvkn ).
    ENDIF.
    ENDIF.
    ENDSELECT.
    ENDFORM.                    "GET_INV_QTY

    Get Sales Outstanding Func2

    FUNCTION ZGET_SALES_OUSTANDING.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(SALESDOCUMENT) TYPE  VBAK-VBELN
    *"     REFERENCE(I_POSNR) TYPE  VBAP-POSNR
    *"  EXPORTING
    *"     REFERENCE(EX_MSMNG) TYPE  VSMNG
    *"----------------------------------------------------------------------
    DATA: L_VSMNG LIKE vbepvb-vsmng.
    Data: lT_VBFA type VBFA occurs 0 with header line,
          lT_VBUP type VBUP occurs 0 with header line,
          lT_VBEP type VBEPVB occurs 0 with header line,
          lT_VBAP type VBAPVB occurs 0 with header line.
    SELECT * FROM vbup INTO TABLE lt_vbup
    WHERE vbeln EQ salesdocument AND
    posnr EQ i_posnr.
    SELECT * FROM vbfa INTO TABLE lt_vbfa
    WHERE vbelv EQ salesdocument AND
    posnv EQ i_posnr.
    SELECT * FROM vbep INTO TABLE lt_vbep
    WHERE vbeln EQ salesdocument AND
    posnr EQ i_posnr .
    SELECT * FROM vbap INTO TABLE lt_vbap
    WHERE vbeln EQ salesdocument AND
    posnr EQ i_posnr .
    call function 'RV_SCHEDULE_CHECK_DELIVERIES'
    exporting
    fbeleg = salesdocument
    fposnr = i_posnr
    tables
    fvbfa = lt_vbfa
    fvbup = lt_vbup
    fxvbep = lt_vbep
    fvbap = lt_vbap.
    loop at lt_vbep where posnr eq i_posnr.
    add lt_vbep-vsmng to l_vsmng. " tot.deliv.quan
    endloop.
    MOVE l_vsmng to EX_MSmng.
    ENDFUNCTION.

    October 24

    Get Sales order Delivered Qty

    *&---------------------------------------------------------------------*
    *& Report  ZGET_SO_OS
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    REPORT  ZGET_SO_OS.
    Data:
    lT_VBFA type VBFA occurs 0 with header line,
    lT_VBUP type VBUP occurs 0 with header line,
    lT_VBEP type VBEPVB occurs 0 with header line,
    lT_VBAP type VBAPVB occurs 0 with header line,
    l_vsmng like vbepvb-vsmng.
    PARAMETERS: P_VBELN LIKE VBAK-VBELN DEFAULT '8911000008',
                P_POSNR LIKE VBAP-POSNR DEFAULT '000010'.
    START-OF-SELECTION.
    SELECT * FROM vbup INTO TABLE lt_vbup
    WHERE vbeln EQ p_vbeln AND
    posnr EQ p_posnr.
    SELECT * FROM vbfa INTO TABLE lt_vbfa
    WHERE vbelv EQ p_vbeln AND
    posnv EQ p_posnr.
    SELECT * FROM vbep INTO TABLE lt_vbep
    WHERE vbeln EQ p_vbeln AND
    posnr EQ p_posnr .
    SELECT * FROM vbap INTO TABLE lt_vbap
    WHERE vbeln EQ p_vbeln AND
    posnr EQ p_posnr .
    call function 'RV_SCHEDULE_CHECK_DELIVERIES'
    exporting
    fbeleg = P_vbeln
    fposnr = P_posnr
    tables
    fvbfa = lt_vbfa
    fvbup = lt_vbup
    fxvbep = lt_vbep
    fvbap = lt_vbap.
    loop at lt_vbep where posnr eq p_posnr.
    add lt_vbep-vsmng to l_vsmng. " tot.deliv.quan
    endloop.
    WRITE: 'Delivered Qty is :' ,l_vsmng.
    end-of-SELECTION.

    October 21

    ABAP中常用的FUNCTION集合

    ABAP中常用的FUNCTION集合 -------------------------------------------------------
    RS_VARIANT_CONTENTS – 获得程序变式的信息
    RS_CHANGE_CREATED_VARIANT – 修改程序变式的信息
    RZL_SLEEP – 将当前程序挂起
    ENQUE_SLEEP – 在继续处理之前等待一个指定的时间。
    ENQUEUE_ESFUNCTION – 锁定一个ABAP程序使它不可以被执行:
    注意不要用SY-REPID来传递你的报表名字,当把SY-REPID作为参数传递给函数模块的时候,SY-REPID的值实际上已经发生了变化。
    RZL_SUBMIT – 提交一个远程报表
    GUI_UPLOAD 上传文件到服务器
    GUI_DOWNLOAD 下载文件到本地
    FILE_GET_NAME 从逻辑文件名得到物理文件路径及文件名。
    FILENAME_GET 弹出一个文件选择对话框。
    SO_SPLIT_FILE_AND_PATH 将一个包含路径的全文件名分割为文件名和路径。
    EPS_GET_FILE_ATTRIBUTES 获得文件属性。
    RZL_READ_DIR_LOCAL 读取应用服务器的目录
    GUI_CREATE_DIRECTORY 在显示服务器端创建一个目录 。
    GUI_DELETE_FILE 在显示服务器端删除一个文件 。
    UPLOAD_FILES 上传一个或多个文件
    MS_EXCEL_OLE_STANDARD_OLE 创建一个文件并自动启动Excel 。
    GUI_REMOVE_DIRECTORY 从显示服务器删除一个目录 。
    EPS_GET_DIRECTORY_LISTING 返回一个本地或网络目录的文件列表。
    RZL_READ_DIR 如果服务器名字左部为空,从本地读取目录,否则读取远程服务器的目录。
    RZL_READ_FILE 如果为给定服务器名字则读取本地文件,否则读取远程服务器文件。
    RZL_WRITE_FILE_LOCAL 将内表保存到显示服务器(not PC). 不使用OPEN DATASET因此避免了授权检查。
    -------------------------------------------------------
    SAPGUI_PROGRESS_INDICATOR – 显示一个进度条
    RPY_TRANSACTION_READ – 给定一个事务代码,获得其程序和屏幕;或给定一个程序和屏幕获得事务代码
    SCROLLING_IN_TABLE –当编写模块池的时候可以用它来处理滚动
    SO_NEW_DOCUMENT_ATT_SEND_API1 - 将文档作为邮件的一部分发送
    SO_SPOOL_READ – 根据SPOOL号获得printer spool
    SO_WIND_SPOOL_LIST – 根据用户浏览printer spool号
    LIST_TO_ASCII –将ABAP报表从 OTF形式转换成ASCII 形式。
    SX_OBJECT_CONVERT_OTF_PDF – 从OTF转换为PDF (SAP 脚本转换)
    SX_OBJECT_CONVERT_OTF_PRT – 从OTF转换为打印机格式(SAP 脚本转换)
    SX_OBJECT_CONVERT_OTF_RAW – 从OTF转换为ASCII(SAP 脚本转换)
    -------------------------------------------------------
    SXPG_CALL_SYSTEM - 检查用户是否有执行某个命令的权限
    SXPG_COMMAND_LIST_GET – 获得一个包含所有定义的外部OS命令的列表.
    SXPG_COMMAND_DEFINITION_GET – 从R/3系统数据库读取单个外部OS命令的定义
    SXPG_COMMAND_CHECK - 检查用户是否有执行某个命令的权限
    SXPG_COMMAND_EXECUTE -检查用户是否有执行某个命令的权限,拥有授权则执行命令
    TERMINAL_ID_GET –返回终端ID
    TH_DELETE_USER – 剔除一个用户,效果同SM04
    TH_ENVIRONMENT – 获得UNIX环境
    TH_POPUP –在特定用户屏幕上显示一个系统消息
    TH_REMOTE_TRANSACTION – 在远程服务器上运行事务代码
    TH_USER_INFO – 获得当前用户的信息 (会话,登陆的工作台等)
    TH_USER_LIST –显示登陆到应用服务器的用户列表
    WRITE_LIST 显示一个列表对象
    WS_EXCEL 启动EXCEL
    WS_VOLUME_GET 获得终端设备标签
    WWW_LIST_TO_HTML 运行一个报表之后,调用这个方法将列表输出转换成HTML
    SD_VBAP_READ_WITH_VBELN 根据销售订单读取表vbap中的信息
    -------------------------------------------------------
    CO_R0_CHECK_DECIMAL_POINT 根据单位检查数据的小数位
    POSTAL_CODE_CHECK 检查邮政编码
    VIEW_MAINTENANCE_CALL 维护表视图
    F4IF_INT_TABLE_VALUE_REQUEST 显示检索help
    TERMINAL_ID_GET 获得终端id
    MESSAGE_TEXT_BUILD 把消息转为文本
    -------------------------------------------------------
    SSF_FUNCTION_MODULE_NAME 根据form名取得对应的函数名(SmartForm)
    SSF_FUNCTION_MODULE_NAME SMARTFORMS输出报表时,生成一个函数名称,然后CALL这个名称
    RS_COVERPAGE_SELECTIONS 获得一个报表的选择参数列表。
    RSLG_WRITE_SYSLOG_ENTRY 往Syslog里写一条记录
    RSPO_SX_OUTPUT_TEXTDATA 将内表中的数据输出到SPOOL
    ALSM_EXCEL_TO_INTERNAL_TABLE将excel文件上传至内表







    DYNP_VALUES_READ – 读取SCREEN字段的值,也可以用来读取报表SELECTION SCREEN。
    DYNP_VALUES_UPDATE - 更新屏幕字段的值。
    GET_GLOBAL_SYMBOLS – 返回一个程序的tables, select options, texts, etc 。甚至包含selection screen的文本定义。
    RPY_DYNPRO_READ – 读取屏幕
    DY_GET_SET_FIELD_VALUE - 获得或者设置屏幕字段的值
    RS_REFRESH_FROM_SELECTOPTIONS –获得当前选择屏幕的内容
    DY_GET_FOCUS – 获得屏幕焦点
    BP_JOBLOG_READ - 获得job log的执行结果。
    GET_JOB_RUNTIME_INFO - 获得job相关信息
    CLPB_EXPORT - 从内表导入到剪贴板。
    CLPB_IMPORT - 从剪贴板导入内表。
    CONVERT_OTF - 将SAP文档(SAP Script)转换成其他类型。
    ABAP_DOCU_DOWNLOAD - 以HTML格式下载ABAP文档。
    ARFC_GET_TID - 以十六进制形式返回终端的IP地址。
    BAL_* - 容纳了SAP的应用程序日志所有的函数模块。
    BP_EVENT_RAISE - 在 ABAP/4 程序中触发一个事件。
    F4IF_SHLP_EXIT_EXAMPLE – F4接口模块。
    FTP_CONNECT – 打开并登陆FTP服务器的连接。
    FTP_COMMAND – 在FTP服务器上执行一个命令。
    FTP_DISCONNECT –关闭指向FTP服务器的连接。
    GET_INCLUDETAB – 获得一个程序的INCLUDES列表。
    GUI_EXEC – 调用一个文件或程序,取代了WS_EXECUTE。
    GUI_GET_DESKTOP_INFO – 获得客户端桌面信息,取代了WS_QUERY。
    GUI_RUN – 启动一个文件或程序。
    HELP_START – 为一个字段显示帮助。
    K_WERKS_OF_BUKRS_FIND – 返回一个特定公司代码的所有工厂。
    POPUP_TO_CONFIRM   --standard dialog Popup
    POPUP_TO_CONFIRM_LOSS_OF_DATA – 弹出一个对话框告知用户有可能丢失数据,询问是否操作继续。
    POPUP_TO_CONFIRM_STEP - 弹出一个对话框询问用户是否操作继续。
    POPUP_TO_CONFIRM_WITH_MESSAGE
    POPUP_TO_CONFIRM_WITH_VALUE
    POPUP_TO_DECIDE
    POPUP_TO_DECIDE_WITH_MESSAGE
    POPUP_TO_DISPLAY_TEXT
    POPUP_TO_SELECT_MONTH – 弹出一个对话框供选择月。
    POPUP_WITH_TABLE_DISPLAY - Provide a display of a table for user to select one, with the value of the table line returned when selected。
    CONVERSION_EXIT_CUNIT_OUTPUT 单位转换
    CLOI_PUT_SIGN_IN_FRONT 将负号前置, SAP默认将负号放在数字后面。
    CONVERSION_EXIT_ALPHA_INPUT 数字串前补0
    CONVERSION_EXIT_ALPHA_OUTPUT 消除数字串前的0
    BAPI_CURRENCY_CONV_TO_EXTERNAL 将金额转换成外部数据格式
    BAPI_CURRENCY_CONV_TO_INTERNAL 将金额转换成内部数据格式
    UNIT_CONVERSION_SIMPLE 衡量单位转换
    SJIS_DBC_TO_SBC 全角转半角
    SJIS_SBC_TO_DBC 半角转换为全角
    TEXT_SPLIT 字符串分割
    CONVERT_TO_LOCAL_CURRENCY 按照指定日期汇率转换金额为指定货币类型
    CONVERT_OTFSPOOLJOB_2_PDF 将OTF spool转换为PDF
    CONVERT_ABAPSPOOLJOB_2_PDF 将ABAP spool转换为PDF
    -------------------------------------------------------
    PRICING 获得定价条件
    PROFILE_GET 从INI文件读取一条记录
    PROFILE_SET 往INI文件写一条记录
    READ_TEXT 读取长文本
    SAVE_TEXT 上传长文本
    -------------------------------------------------------
    REGISTRY_GET 从注册表读取一条记录
    REGISTRY_SET 在注册表里设置一条记录
    RFC_ABAP_INSTALL_AND_RUN 当MODE参数值为‘F’时运行PROGRAM表中的程序'.
    RH_GET_ACTIVE_WF_PLVAR 获得激活的HR计划
    RH_START_EXCEL_WITH_DATA 启动Excel并用内表给文件赋值
    RH_STRUC_GET 返回所有相关的组织信息
    -------------------------------------------------------
    RP_CALC_DATE_IN_INTERVAL 年月日加减
    DATE_CHECK_PLAUSIBILITY 日期有效性检查
    SD_DATETIME_DIFFERENCE 两日期作差
    DATE_CONVERT_TO_FACTORYDATE 把输入日期转为工厂日历日期
    MONTH_NAMES_GET 获得所有的月和名字
    -------------------------------------------------------
    F4_DATE     弹出一个窗口显示一个日历允许用户选择一个日期。
    RP_LAST_DAY_OF_MONTHS 获得一个月的最后一天
    FIRST_DAY_IN_PERIOD_GET 获得期间首日
    LAST_DAY_IN_PERIOD_GET 获得期间末日
    DATE_GET_WEEK                    返回一个日期所在的周数。
    HOLIDAY_GET 基于工厂日历/节日日历提供了一个节日表。

    Dialog Input Check

    Input formatThe values entered in the input fields on the screen must correspond to the data format of the corresponding screen field. For example, the format of a date field (type DATS) is eight characters and has the format YYYYMMDD. All of the characters must be numeric. MM must be 12 or less, and DD must be 31 or less. The system also checks that the specified day is valid for the month.
    ABAP Dictionary ChecksIf you create an input field in the Screen Painter by copying an ABAP Dictionary field, the screen checks whether:
    ·        The value satisfies any foreign key relationship to another database table, that is, the system checks whether the value is contained in the check table as a foreign key. This is only checked if the Foreign key attribute is set in the Screen Painter for the input field. The input check is not necessarily identical with the input help. The programmer is responsible for ensuring that the input help presents values that will all pass any foreign key check.
    ·        That the value is one of the fixed values of the domain of the fields, that is, the system checks the definition of the underlying domain in the ABAP Dictionary. The fixed values of the domain can also be used as input help. However, the value table of a domain is not checked. It is only used as a default value for the check tables of the fields that refer to the domain.

    Automatic input checks
    PROGRAM demo_dynpro_automatic_checks.
    DATA: ok_code TYPE sy-ucomm,
          date TYPE d.

    TABLES demo_conn.
    CALL SCREEN 100.
    MODULE init_screen_100 OUTPUT.
      SET PF-STATUS 'STATUS_100'.
    ENDMODULE.

    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.

    MODULE pai INPUT.
      MESSAGE i888(sabapdocu) WITH text-001.
    ENDMODULE.

    The next screen (statically defined) for screen 100 is 100. It has the following layout:

    The date field date from the program is assigned to the input field Date. The other input fields are the CARRID; CONNID, and MARK components of the ABAP Dictionary structure DEMO_CONN. All of the fields are mandatory. The function code of the pushbutton is EXECUTE.
    In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE.
    The screen flow logic is as follows:
    PROCESS BEFORE OUTPUT.
      MODULE init_screen_100.

    PROCESS AFTER INPUT.
      MODULE cancel AT EXIT-COMMAND.
      MODULE pai.

    The user must fill all of the input fields with valid values before the PAI module can be called:
    ·         All of the input fields must contain values
    ·         The date entry must have the correct format
    ·         The airline must be in the check table SCARR
    ·         The flight number must exist for the corresponding airline in the check table SPFLI
    ·         The selection MARK must be one of the fixed values of the domain S_FLAG.
    The user can leave the screen using Cancel (, F12) without entering all values correctly, since the module call is programmed using AT EXIT-COMMAND.




    Checking Input in the Screen Flow Logic   There are two special variants of the FIELDstatement that you can use in PAI processing to check the values of screen fields in the screen flow logic. However, this method is obsolete and should no longer be used. It is only supported for compatibility reasons.
    Checking a Value ListYou can check a screen field against a value list as follows:
    FIELD f VALUES (v1, v2,...).
    The individual entries v1, v2,... in the list can have the following format:
    ·        [NOT] val
    ·        [NOT] BETWEEN val1 AND val2
    You can check against single fields val or intervals between val1 and val2. The comparison fields must have the value range of data type CHAR or NUMC, must be enclosed in inverted commas, and must be written in uppercase. If the check fails, an error message is displayed and the corresponding field is again ready for entry.
    The input help for f can also use the value list in the FIELD statement. This helps the user to enter only correct values.
    The functions of the FIELD statement for controlling data transport also apply when you use the VALUES addition.
    Checking Against Database TablesYou can compare a screen field with a database table follows:
    FIELD f SELECT   *
                FROM  dbtab
                WHERE k1 = f1 AND k2 = f2 AND...

                [INTO  tables_area]
                WHENEVER [NOT] FOUND SEND ERRORMESSAGE|WARNING
                                          [num [WITH h1 ... h4]].

    The FIELD statement is combined with a SELECTstatement. The syntax of the SELECT statement must be entered exactly as shown above. In the WHERE condition, no comparison operators other than the equals sign (=) are allowed, not even EQ. In the WHEREcondition, the fields of the primary key k1 k2 ... of the database table dbtab are checked against the screen fields f1 f2 ... If a matching entry is found, you can write it into the table work area of a screen field, which was defined by transfer from the ABAP Dictionary. You can also send an error or warning message depending on the outcome of the search, which makes the input field for f ready for input again.
    num allows you to specify a message number from the message class specified in the MESSAGE-ID addition of the first statement in the program. In this case, the message class can only be two characters long. If you do not specify a message class, the system displays a default message. If you use WITH, you can pass literals or screen fields to any placeholders (&) within the message.
    The input help for f can also use the SELECT statement after FIELD. This helps the user to enter only correct values.
    You can also use the SELECT statement in screen flow logic without combining it with the FIELD statement. This allows you to fill screen fields with the contents of database tables without calling ABAP modules. The functions of the FIELD statement for controlling data transport also apply when you use SELECT.

    Checking Inputs in the Screen Flow Logic
    PROGRAM demo_dynpro_value_select MESSAGE-ID dw.
    DATA: ok_code TYPE sy-ucomm,
          carrier TYPE spfli-carrid,
          connect TYPE spfli-connid.
    CALL SCREEN 100.
    MODULE init_screen_0100 OUTPUT.
      SET PF-STATUS 'STATUS_100'.
    ENDMODULE.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE module_1 INPUT.
      MESSAGE i888(sabapdocu) WITH text-001 carrier
                            text-002 connect.
    ENDMODULE.
    MODULE module_2 INPUT.
      MESSAGE i888(sabapdocu) WITH text-001 carrier
                            text-002 connect.
    ENDMODULE.
    The next screen (statically defined) for screen 100 is 100. It has the following layout:

    The program fields carrier and connect are assigned to the input fields. The function code of the pushbutton is EXECUTE.
    In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE.
    The screen flow logic is as follows:
    PROCESS BEFORE OUTPUT.
      MODULE init_screen_0100.
    PROCESS AFTER INPUT.
      MODULE cancel AT EXIT-COMMAND.
      FIELD carrier VALUES (NOT 'AA', 'LH', BETWEEN 'QF' AND 'UA').
      MODULE module_1.
      FIELD connect SELECT  *
                      FROM  spfli
                      WHERE carrid = carrier AND connid = connect
                      WHENEVER NOT FOUND SEND ERRORMESSAGE 107
                                              WITH carrier connect.
      MODULE module_2.

    The user must enter a value for carrier that is in the list following VALUES before module_1 is called. When module_1 is called, connect has not yet been transported.
    Next, the user can only enter a value for connect that exists in the database table SPFLI as part of a primary key together with carrier. If not, error message 107 from message class AT is displayed in the status bar:
    Unable to find any entries for key & &.
    Only when a correct value has been entered will connect be transported and module_2 called.



    Input Checks in Dialog Modules   You cannot perform input checks in PAI modules of programs until you have transported the contents of the input fields to the ABAP program. You can then use logical expressions to check the values that the user entered. You should then allow the user to correct any wrong entries before calling further modules.
    You can do this by sending warning (type W) or error (type E) messages from PAI modules that are called in conjunction with the statements FIELD and CHAIN.
    Checking Single FieldsIf you send a warning or error message from a module mod  that you called using a FIELDstatement as follows:
    FIELD f MODULE mod.
    the corresponding input field on the current screen is made ready for input again, allowing the user to enter a new value. If the field is only checked once, the PAI processing continues directly after the FIELDstatement, and the preceding modules are not called again.
    Checking a Set of FieldsIf a warning or an error message is sent in a module mod1 mod2 … that you called within a processing chain:
    CHAIN.
      FIELD: f1, f2,...
      MODULE mod1.
      FIELD: g1, g2,...
      MODULE mod2.
    ...
    ENDCHAIN.

    all of the input fields on the current screen that belong to the processing chain are made ready for input again – including those that are in FIELD statements after the MODULEstatement. All the other fields are not ready for input.  Even if a MODULE statement appears within a processing chain, combined with a FIELD statement, all of the input fields in the chain are made ready for input again – not just the field in question. The user can repeat the input. If the fields in the processing chain are only checked once, the PAI processing continues directly after the automatic checks at the CHAINstatement, and the preceding modules are not called again.
    Controlling Input and Data TransportIf you use the FIELD statement outside a processing chain, only a single field is made ready for input when a warning or error message is displayed. If you use FIELD statements between CHAIN - ENDCHAIN, this controls a set of fields. All of the fields controlled by a FIELDstatement are transported back to the screen, bypassing PBO processing. This means that any changes made to the field contents before the message become visible on the screen. This also applies to information
    Checking Fields RepeatedlyYou may sometimes need to specify the same field in more than one FIELD or CHAIN statement. If one of the corresponding modules sends a warning or error message, PAI processing resumes with the value that the user corrected. However, in this case, processing cannot simply resume at the corresponding FIELD or CHAIN statement if the field in question has already been included in an earlier FIELD or CHAIN statement.
    Instead, all of the FIELD and CHAIN statements containing a field in which an error occurred are repeated. PAI processing resumes at the first FIELD or CHAINstatement containing one or several of the fields in which the error occurred and that the user changed the last time the screen was displayed.
             PROCESS AFTER INPUT.
             FIELD f1 MODULE m1.
             FIELD f2 MODULE m2.

             CHAIN.
                FIELD: f1, f2, f3.
                FIELD: f4, f5, f1.
                MODULE m3.
                MODULE m4.
             ENDCHAIN.

             CHAIN.
                FIELD: f6.
                MODULE m5.
             ENDCHAIN.

             CHAIN.
                FIELD f4.
                MODULE m6.
             ENDCHAIN.

    If module m6contains a warning or error message, the screen is displayed again, after which processing resumes with the first CHAIN statement. Module m3 is called since this is the first occurrence of the field f4.
    Remaining Functions in the FIELD StatementAll of the functions of the FIELD and CHAINstatements for controlling data transport and conditional module calls can also be used in combination with warning and error messages. The contents of each field are transported at the FIELD statement in which the field occurs. If a warning or error message occurs in a conditional module of a processing chain, all of the fields in that chain will be ready for input when the screen is redisplayed, although not all of the fields will have been transported.
    If a warning or error message occurs in a module that is not linked with a FIELD or CHAIN statement, none of the fields on the screen will be ready for input. In this case, the user can only exit the program, but only if a corresponding unconditional module call is provided.

    Input Checks in Dialog Modules
    PROGRAM demo_dynpro_field_chain.
    DATA: ok_code TYPE sy-ucomm,
          input1 TYPE i, input2 TYPE i, input3 TYPE i,
          input4 TYPE i, input5 TYPE i, input6 TYPE i,
          sum TYPE i.
    CALL SCREEN 100.
    MODULE init_screen_100 OUTPUT.
      CLEAR: input1, input2, input3, input4, input5, input6.
      SET PF-STATUS 'STATUS_100'.
    ENDMODULE.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE module_1 INPUT.
      IF input1 < 50.
        MESSAGE e888(sabapdocu) WITH text-001 '50' text-002.
      ENDIF.
    ENDMODULE.
    MODULE module_2 INPUT.
      IF input2 < 100.
        MESSAGE e888(sabapdocu) WITH text-001 '100' text-002.
      ENDIF.
    ENDMODULE.
    MODULE module_3 INPUT.
      IF input3 < 150.
        MESSAGE e888(sabapdocu) WITH text-001 '150' text-002.
      ENDIF.
    ENDMODULE.
    MODULE chain_module_1 INPUT.
      IF input4 < 10.
        MESSAGE e888(sabapdocu) WITH text-003 '10' text-002.
      ENDIF.
    ENDMODULE.
    MODULE chain_module_2 INPUT.
      CLEAR sum.
      sum = sum + : input4, input5, input6.
      IF sum <= 100.
        MESSAGE e888(sabapdocu) WITH text-004 '100' text-002.
      ENDIF.
    ENDMODULE.
    MODULE execution INPUT.
      MESSAGE i888(sabapdocu) WITH text-005.
    ENDMODULE.
    The next screen (statically defined) for screen 100 is 100. It has the following layout:

    The screen fields input1 through input6 are assigned to the input fields. The function code of the pushbutton is EXECUTE.
    In the GUI status STATUS_100, the icon (F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE with the function type <blank>.
    The screen flow logic is as follows:
    PROCESS BEFORE OUTPUT.
      MODULE init_screen_100.
    PROCESS AFTER INPUT.
      MODULE cancel AT EXIT-COMMAND.
      FIELD input1 MODULE module_1.
      FIELD input2 MODULE module_2.
      FIELD input3 MODULE module_3.
      CHAIN.
        FIELD input4.
        MODULE chain_module_1.
        FIELD input5.
        FIELD input6 MODULE chain_module_2.
      ENDCHAIN.
      MODULE EXECUTION.

    This program demonstrates how you can check input fields in dialog modules.
    The fields input1 through input3 are checked independently of each other in the modules module_1 through module_3. As long as the user does not enter a corresponding value, the screen is repeatedly displayed with the appropriate field ready for input.
    The fields input4 through input6 are checked together in a processing chain. If input4 does not satisfy the condition in chain_module_1, all three fields are again ready for input. The same applies if the three fields do not satisfy the condition in chain_module_2.
    The EXECUTION module, from which an information message is displayed, is not executed until all six fields satisfy the appropriate conditions.

    Print out the Additonal Charge in a FORM

    Step1 : Modify Standard Print program.
    Step2: Change the condition type's description (Maintain condition type)







    "Michael 2009.02.20
    DATA: BEGIN OF K OCCURS 50.
          INCLUDE STRUCTURE KOMVD.
    DATA: P(2) TYPE C.
    DATA: END OF K.
    DATA: BEGIN OF IT_KONV OCCURS 50.
            INCLUDE STRUCTURE KOMVD.
    DATA: END OF IT_KONV.

    ---------------------------------------------------------------------*
    *       FORM HEADER_PRICE_PRINT                                       *
    *---------------------------------------------------------------------*
    *       Printout of the header prices                                 *
    *---------------------------------------------------------------------*
    FORM header_price_print.
    "Michael Adding for item discount separated show 2009.02.20
    DATA: lt_VTEXT LIKE TKOMVD-VTEXT.
    data: l_index like sy-tabix.
    READ TABLE tkomv with key KSCHL = 'ZDIS'.
    if sy-subrc eq 0.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_KONV
       FROM KONV WHERE KNUMV = VBDKR-KNUMV
       AND KSCHL = 'ZDIS' and KWERT < 0.
       if it_konv[] is not INITIAL.
         READ TABLE TKOMVD WITH KEY kschl = 'ZDIS'.
         if sy-subrc eq 0.
           lt_VTEXT = TKOMVD-vtext.
         Loop at it_konv.
           it_konv-VTEXT =   lt_VTEXT.
          modify it_konv index sy-tabix.
         ENDLOOP.
         TKOMVD[] = IT_KONV[].
         endif.
       ENDIF.
      ENDIF.
    "End of adding
      LOOP AT hkomvd.
        l_index = sy-tabix.
        AT FIRST.
          IF komk-supos NE 0.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'ITEM_SUM'.
          ELSE.
            CALL FUNCTION 'WRITE_FORM'
              EXPORTING
                element = 'UNDER_LINE'
              EXCEPTIONS
                element = 1
                window  = 2.
            IF sy-subrc NE 0.
              PERFORM protocol_update.
            ENDIF.
          ENDIF.
        ENDAT.

        komvd = hkomvd.
      "Michael added 2009.02.20
        CLEAR TKOMVD-KOEIN.
        CLEAR TKOMVD-AWEIN.
        cleaR TKOMVD-KMEIN.
        modify Tkomvd index l_index.
        MOVE-CORRESPONDING TKOMVD TO K. "Michael 2009.02.20
        K-P = TKOMVD-KPOSN+4(2).
      "End of adding

    ZUPDATE_DATA_OO

    *&---------------------------------------------------------------------*
    *& Report  ZUPDATE_DATA_OO
    *&
    *&---------------------------------------------------------------------*
    *& Author              : CHUNG NAM INTERNATIONAL CO.,LTD. MICHAELCHOW
    *& Creation Date       : 20.11.2008
    *& Program Type        : Executable Programs
    *& Logical DB          : [Nil]
    *& Text Elements
    *&   (Titles&Headers)  : [Nil]
    *&   (Selection Texts) : [Nil]
    *&   (Text symbols)    : [Nil]
    *& GUI Status          : [Nil] OR [Standard]
    *& Variants            : [Nil] OR Variant
    *& Message Class       : [Nil]
    *& Description         :
    *&
    *&---------------------------------------------------------------------*
    *& Modifications       :
    *& ID   Date        Programmer   Description
    *&
    *&---------------------------------------------------------------------*
    REPORT  ZUPDATE_DATA_OO.
    * Define Screen Container
    DATA: obj_container TYPE REF TO cl_gui_custom_container.
    DATA: o_error       TYPE REF TO i_oi_error,
          o_control     TYPE REF TO i_oi_container_control,
          o_document    TYPE REF TO i_oi_document_proxy,
          o_spreadsheet TYPE REF TO i_oi_spreadsheet.
    * Data declarations.
    DATA: t_files       TYPE filetable,
          s_files       TYPE file_table,
          v_doc_name    TYPE char256,
          v_changed     TYPE int4,
          v_rcode       TYPE int4,
          t_ranges      TYPE soi_range_list,
          s_ranges      TYPE soi_range_item,
          t_data        TYPE soi_generic_table,
          s_data        TYPE soi_generic_item,
          v_action      TYPE int4.
    * Initialization event.
    INITIALIZATION.
    CLASS c_oi_errors DEFINITION LOAD.
    * Create Instance control for container
      CALL METHOD c_oi_container_control_creator=>get_container_control
           IMPORTING control = o_control
                     error   = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Create generic container linked to container in screen 100
      CREATE OBJECT obj_container
        EXPORTING
         container_name               = 'CONTAINER'
        EXCEPTIONS
         cntl_error                  = 1
         cntl_system_error           = 2
         create_error                = 3
         lifetime_error              = 4
         lifetime_dynpro_dynpro_link = 5
         others                      = 6.
      IF sy-subrc <> 0.
        MESSAGE e208(00) WITH 'Error creating container'.
      ENDIF.
    * Establish connection to GUI Control
      CALL METHOD o_control->init_control
          EXPORTING r3_application_name = 'Excel Document Container'
                     inplace_enabled     = 'X'
                     parent              = obj_container
           IMPORTING error               = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Create Document Proxy
      CALL METHOD o_control->get_document_proxy
           EXPORTING document_type   = soi_doctype_excel_sheet
           IMPORTING document_proxy  = o_document
                     error           = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Start-of-selection.
    START-OF-SELECTION.
    * Call dialog to navigate to file
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
         EXPORTING
           default_extension       = '.xls'
           file_filter             = '*.xls'
           initial_directory       = 'C:\'
        CHANGING
           file_table              = t_files
           rc                      = v_rcode
           user_action             = v_action
        EXCEPTIONS
           file_open_dialog_failed = 1
           cntl_error              = 2
           error_no_gui            = 3
           OTHERS                  = 4.
      IF sy-subrc <> 0.
        MESSAGE e208(00) WITH 'FILE_OPEN_DIALOG'.
      ENDIF.
    * Only continue if User hasn't cancelled
      CHECK: v_action = 0.
    * Determine filename to open Excel document
      READ TABLE t_files INDEX 1 INTO s_files.
      IF sy-subrc = 0.
        CONCATENATE 'FILE://' s_files-filename INTO v_doc_name.
      ELSE.
        MESSAGE e208(00).
      ENDIF.  "sy-subrc = 0
    * Open Spreadsheet in SAPWORKDIR
      CALL METHOD o_document->open_document
           EXPORTING open_inplace     = 'X'
                     document_title   = 'Excel'
                     document_url     = v_doc_name
                     no_flush         = ''
           IMPORTING error            = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Open Spreadsheet interface
      CALL METHOD o_document->get_spreadsheet_interface
           EXPORTING no_flush        = ''
           IMPORTING sheet_interface = o_spreadsheet
                     error           = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Set selection for 1000 rows
      CALL METHOD o_spreadsheet->set_selection
                   EXPORTING top   = 1
                             left  = 1
                             rows  = '1000'
                             columns = '36'.
    * Define Range in spreadsheet
      CALL METHOD o_spreadsheet->insert_range
             EXPORTING name      = 'Test'
                       rows      = '1000'
                       columns   = '36'
                       no_flush  = ''
             IMPORTING error     = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
      s_ranges-name    = 'Test'.
      s_ranges-rows    = '1000'.
      s_ranges-columns = '36'.
      APPEND s_ranges TO t_ranges.
    * Get data
      CALL METHOD o_spreadsheet->get_ranges_data
             EXPORTING all       = ''
                       no_flush  = ''
             IMPORTING contents  = t_data
                       error     = o_error
             CHANGING  ranges    = t_ranges.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF."* Close document
    * Close the document
      CALL METHOD o_document->close_document
             EXPORTING do_save     = ''
                       no_flush    = ''
             IMPORTING has_changed = v_changed
                       error       = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Clear Document Resources
      CALL METHOD o_document->release_document
             EXPORTING no_flush = ''
             IMPORTING error    = o_error.
      IF o_error->has_failed = 'X'.
        CALL METHOD o_error->raise_message
             EXPORTING type = 'E'.
      ENDIF.
    * Clear table of file names
      FREE: t_files,
            o_control.
    * Display the data
      LOOP AT t_data INTO s_data.
        AT NEW row.
          SKIP.
        ENDAT.
        WRITE:(10) s_data-value.
      ENDLOOP.

    How to find the BADI

    1. BADIs are storaged in below tables:
                                  SXS_INTER    --------Exit: Definition side: Interfaces
                                  SXC_EXIT      --------Exit: Implementation side: Assignment: Exit - Implementation
                                  SXC_CLASS  --------Exit, implementation side: Class assignment (multiple)
                                  SXC_ATTR     --------Exit: Implementation side: Attributes
    2.  SAP program will  call "CL_EXITHANDER=>GET_INSTANCE" to check the object if it exists and return the instance, just search data from above tables and its' views V_EXT_IMP and V_EXT_ACT
    3.So,we can according those information using ST05 to trace the BADIs.

    4. Using SE18  to find the interface, use SE19 to carry out the Implementation.