CONVERSION_EXIT_ALPHA_INPUT  problem

Hi,
I am adding leading zeros to a number using the CONVERSION_EXIT_ALPHA_INPUT Function module.
But i am not getting what i require in case of a negative number.
Eg:
I am getting perfectly correct result in case of postive numbers.
input = 1500
output = 00000000001500.
but in case of negative number i am not getting leading zeros appended.
input = 1500-
output = 1500-.
Kindly help me out.
Thanks

Hi,
Try in this way.
DATA: l_data(8) TYPE c VALUE '-20'
IF l_data LT 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = l_data+1
IMPORTING
   OUTPUT        = l_data+1
ELSE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = l_data
IMPORTING
   OUTPUT        = l_data
ENDIF.
This logic assumes u have negative sign as first character when the number is negative
Thanks,
Vinod.

Similar Messages

  • Problem when I execute program SCM in background

    Hi experts,
        I am with problem when I execute a program (SCM) in background. I inserted a new field (estoque_seg(10)) and the process stopped at execute in background.When I call transaction and press F8, works but for this, I need jump the consistence  IF sy-batch IS INITIAL....Dont has any bath imput, only functions. Any idea?
    Follow below the code:
    Estrutura para tabela ENTRADA
    DATA: BEGIN OF st_entrada,
            matnr(40)            TYPE c,
            werks(20)            TYPE c,
            ponto_abas(10)       TYPE c,
            estoque_max(10)      TYPE c,
            cobertura(10)        TYPE c,
            estoque_seg(10)      TYPE c, " Erlon Lourenço 20/01/2011
          END OF st_entrada.
    Estrutura para tabela de LOG
    *TYPES: BEGIN OF st_saida,
           pernr(8)             TYPE c ,
           date(10)             TYPE c,
           er_contribuition(15) TYPE c,
           tax(15)              TYPE c,
           msg_erro(80)         TYPE c,
         END OF st_saida.
    Tabela para obter descricao da mensagem
    *DATA: ti_saida TYPE STANDARD TABLE OF st_saida WITH HEADER LINE
                                                  INITIAL SIZE 0.
    Tabela que recebera o arquivo texto
    DATA: BEGIN OF ti_entrada OCCURS 0.
            INCLUDE STRUCTURE st_entrada.
    DATA: END OF ti_entrada.
    DATA: BEGIN OF it_matid OCCURS 0,
      matnr TYPE /sapapo/matkey-matnr,
      matid TYPE /sapapo/matkey-matid,
    END OF it_matid.
    DATA: BEGIN OF it_locid OCCURS 0,
      locno TYPE /sapapo/loc-locno,
      locid TYPE /sapapo/loc-locid,
    END OF it_locid.
    DATA: BEGIN OF it_matlotsz OCCURS 0,
      target_dur TYPE /sapapo/matlotsz-target_dur,
      END OF it_matlotsz.
    DATA:        wa_matloc       LIKE /sapapo/matloc   OCCURS  0 WITH HEADER LINE,
                 wa_matlsim      LIKE /sapapo/matlsim  OCCURS  0 WITH HEADER LINE,
                 wa_matlotsz     LIKE /sapapo/matlotsz OCCURS  0 WITH HEADER LINE.
    Variáveis Globais
    DATA: v_tabix   TYPE sy-tabix,
          v_vrsioid TYPE /sapapo/apo01-vrsioid,
          v_tam     TYPE i.
        Select-Options & Parameters
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:  p_versao    TYPE /sapapo/apo01-vrsioex OBLIGATORY DEFAULT '000',
                 p_abas  AS CHECKBOX  ,
                 p_est   AS CHECKBOX  ,
                 p_cober AS CHECKBOX  ,
                 p_estsg AS CHECKBOX.   " ERLON LOURENCO - 20/01/2012 - Estoque Segurança
    SELECTION-SCREEN END OF BLOCK b1.
        Start-of-Selection
    START-OF-SELECTION.
      PERFORM consiste.
      PERFORM f_upload.
      PERFORM f_processa_batch.
      PERFORM f_saida_dados.
      MESSAGE i000 WITH 'Processo encerrado com Sucesso'.
    END-OF-SELECTION.
    *&      Form  F_UPLOAD
          text
    -->  p1        text
    <--  p2        text
    FORM f_upload .
      DATA: lc_file TYPE string.
      TYPES: BEGIN OF st_ent,
                cam(80),
             END OF st_ent.
      DATA: ti_ent TYPE STANDARD TABLE OF st_ent WITH HEADER LINE
                                                  INITIAL SIZE 0.
      RANGES: r_file       FOR zget0001-field_content.
      r_file[] = zbs_constantes=>obter( i_bukrs = space i_field = 'FILE' i_process = 'PONTO-REAB' ).
      READ TABLE r_file INDEX 1.
      lc_file = r_file-low.
      CLEAR: ti_entrada,
             ti_entrada[],
             ti_ent,
             ti_ent[].
    abrir arquivo para leitura
      OPEN DATASET lc_file FOR INPUT  IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        MESSAGE i000 WITH text-e01.
        STOP.
      ENDIF.
    Leitura de arquivos
      DO.
        READ DATASET lc_file INTO ti_ent.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND ti_ent.
      ENDDO.
    Fechamento do arquivo
      CLOSE DATASET lc_file.
      LOOP AT ti_ent.
        SPLIT ti_ent AT ';' INTO ti_entrada-matnr ti_entrada-werks ti_entrada-ponto_abas ti_entrada-estoque_max ti_entrada-cobertura ti_entrada-estoque_seg.
        APPEND ti_entrada.
      ENDLOOP.
    ENDFORM.                    " F_UPLOAD
    *&      Form  F_PROCESSA_BATCH
          text
    -->  p1        text
    <--  p2        text
    FORM f_processa_batch .
      LOOP AT ti_entrada.
        v_tabix = sy-tabix.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-matnr
          IMPORTING
            output = ti_entrada-matnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-ponto_abas
          IMPORTING
            output = ti_entrada-ponto_abas.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-estoque_max
          IMPORTING
            output = ti_entrada-estoque_max.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-cobertura
          IMPORTING
            output = ti_entrada-cobertura.
    IA - ERLON LOURENCO - 20/01/2012
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = ti_entrada-estoque_seg
          IMPORTING
            output = ti_entrada-estoque_seg.
    FA - ERLON LOURENCO - 20/01/2012
        MODIFY ti_entrada INDEX v_tabix.
      ENDLOOP.
      CLEAR: it_matid,
             it_matid[],
             it_locid,
             it_locid[],
             wa_matlsim,
             wa_matlsim[],
             wa_matloc,
             wa_matloc[].
      SELECT matnr matid INTO TABLE it_matid FROM /sapapo/matkey
      FOR ALL ENTRIES IN ti_entrada WHERE matnr = ti_entrada-matnr.
      SELECT locno locid INTO TABLE it_locid FROM /sapapo/loc
      FOR ALL ENTRIES IN ti_entrada WHERE locno = ti_entrada-werks.
      IF p_versao = '000'.
        LOOP AT ti_entrada.
          READ TABLE it_matid WITH KEY matnr = ti_entrada-matnr.
          IF sy-subrc = 0 .
            READ TABLE it_locid WITH KEY locno = ti_entrada-werks.
            IF sy-subrc = 0.
              SELECT SINGLE * INTO wa_matloc FROM /sapapo/matloc WHERE matid = it_matid-matid  AND
                                                                       locid = it_locid-locid.
              IF sy-subrc = 0.
                IF p_abas = 'X'.
                  wa_matloc-reord    = ti_entrada-ponto_abas.
                ENDIF.
                IF p_est = 'X'.
                  wa_matloc-maxstock = ti_entrada-estoque_max.
                ENDIF.
                " IA - Erlon Lourenço - 23/01/2012
                if p_estsg = 'X'.
                  wa_matloc-safty    = ti_entrada-estoque_seg.     " Erlon Lourenço - 23/01/2012
                endif.
                "FA - Erlon Lourenço - 23/01/2012
                IF p_abas  = 'X'   OR
                   p_est   = 'X'   OR
                   p_estsg = 'X'.      " Erlon Lourenço - 23/01/2012
                  APPEND wa_matloc TO wa_matloc.
                ENDIF.
                SELECT SINGLE * INTO wa_matlotsz FROM /sapapo/matlotsz WHERE lszid = wa_matloc-lszid.
                IF sy-subrc = 0.
                  IF p_cober = 'X'.
                    wa_matlotsz-target_dur = ti_entrada-cobertura.
                    APPEND wa_matlotsz TO wa_matlotsz.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.   " LOOP AT ti_entrada.
      ELSE.
    Verifica versáo para saber se preenche a tabela wa_matlsim
        SELECT SINGLE vrsioid INTO v_vrsioid FROM /sapapo/apo01 WHERE vrsioex = p_versao.
        IF sy-subrc = 0.
          SELECT * INTO TABLE wa_matlsim FROM /sapapo/matlsim WHERE simid = v_vrsioid.
          IF wa_matlsim[] IS NOT INITIAL.
            LOOP AT ti_entrada.
              READ TABLE it_matid WITH KEY matnr = ti_entrada-matnr.
              IF sy-subrc = 0 .
                READ TABLE it_locid WITH KEY locno = ti_entrada-werks.
                IF sy-subrc = 0.
                  READ TABLE wa_matlsim WITH KEY matid = wa_matloc-matid
                                                 locid = wa_matloc-locid.
                  IF sy-subrc = 0.
                    wa_matlsim-reord    = ti_entrada-ponto_abas.
                    wa_matlsim-maxstock = ti_entrada-estoque_max.
                    wa_matlsim-safty    = ti_entrada-estoque_seg.     " Erlon Lourenço - 23/01/2012
                    MODIFY wa_matlsim INDEX v_tabix.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDLOOP.  " LOOP AT ti_entrada.
          ENDIF.     " IF wa_matlsim[] IS NOT INITIAL.
        ENDIF.     " IF sy-subrc = 0. 1º
      ENDIF.     "IF p_versao = '000'
    Funcáo que atualiza campos nas bases de dados.
      CALL FUNCTION '/SAPAPO/DM_PRODUCTS_POST'
        EXPORTING
          iv_vb         = 'U'
        TABLES
          it_matloc     = wa_matloc
          it_matlsim    = wa_matlsim
          it_matlotsz   = wa_matlotsz
        EXCEPTIONS
          not_qualified = 1
          insert_failed = 2
          update_failed = 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.
    ENDFORM.                    " F_PROCESSA_BATCH
      FORM  BDC_DYNPRO
    *&      Form  F_SAIDA_DADOS
          text
    -->  p1        text
    <--  p2        text
    FORM f_saida_dados .
    IF ti_saida[] IS NOT INITIAL.
       DATA: lc_file TYPE string.
       lc_file = p_erros.
       CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
      BIN_FILESIZE                    =
           filename                        = lc_file
      FILETYPE                        = 'ASC'
         TABLES
           data_tab                        = ti_saida
      FIELDNAMES                      =
        EXCEPTIONS
          file_write_error                = 1
          no_batch                        = 2
          gui_refuse_filetransfer         = 3
          invalid_type                    = 4
          no_authority                    = 5
          unknown_error                   = 6
          header_not_allowed              = 7
          separator_not_allowed           = 8
          filesize_not_allowed            = 9
          header_too_long                 = 10
          dp_error_create                 = 11
          dp_error_send                   = 12
          dp_error_write                  = 13
          unknown_dp_error                = 14
          access_denied                   = 15
          dp_out_of_memory                = 16
          disk_full                       = 17
          dp_timeout                      = 18
          file_not_found                  = 19
          dataprovider_exception          = 20
          control_flush_error             = 21
          OTHERS                          = 22
       IF sy-subrc <> 0.
         MESSAGE i005 WITH 'Error to unload file !'.
         STOP.
       ENDIF.
    ENDIF.
    ENDFORM.                    " F_SAIDA_DADOS
    *&      Form  CONSISTE
          text
    -->  p1        text
    <--  p2        text
    FORM consiste .
      IF p_abas  IS INITIAL  AND
         p_est   IS INITIAL  AND
         p_cober IS INITIAL AND
         p_estsg IS INITIAL.   " ERLON LOURENCO - 20/01/2012 - Estoque Segurança
        MESSAGE i000 WITH text-e03.
        STOP.
      ENDIF.
      IF sy-batch IS INITIAL.
        MESSAGE i000 WITH text-e02.
        STOP.
      ENDIF.
    Best regards,
    Erlon Lourenço
    Edited by: Erlon Louren on Jan 27, 2012 11:09 AM

    Hi Raja,
                Check weather there are  any enhancements to the datasource.If yes once check the code in CMOD.Seems there is some discrepency in that.
    Regards
    Karthik

  • Problem in using FM SELECT_TEXT

    Hi friends,
    I have a problem in using fm SELECT_TEXT.
    Here I want to fetch Material PO text in Material master to my report.
    I just dont know in which field of table "it_thead" the actual text is available.\
    I tried debugging the program but was not successful.
    I have also tried using READ_TEXT but it gives an error if no Text exists.
        CALL FUNCTION 'SELECT_TEXT'
          EXPORTING
            client     = sy-mandt
            object     = 'MATERIAL'
            name       = wrk_matnr
            id         = 'BEST'
            language   = sy-langu
          TABLES
            selections = it_thead.
    How do i print the actual MAterial PO text in IT_THEAD ?
    hope u understand the question...please do let me know if any details are required from myside..

    Hi,
    My mistake.
    Check below sample code.
    PARAMETERS: po_matnr TYPE mara-matnr.
    DATA: i_lines TYPE STANDARD TABLE OF tline,
          wa_lines TYPE tline,
          l_matnr TYPE thead-tdname.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = po_matnr
    IMPORTING
       OUTPUT        = po_matnr
    MOVE po_matnr TO l_matnr.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
    *   CLIENT                        = SY-MANDT
        ID                            = 'BEST'
        LANGUAGE                      = sy-langu
        NAME                          = l_matnr              "Pass material with leading zeros
        OBJECT                        = 'MATERIAL'
    *   ARCHIVE_HANDLE                = 0
    *   LOCAL_CAT                     = ' '
    * IMPORTING
    *   HEADER                        =
      TABLES
        LINES                         = i_lines
    EXCEPTIONS
       ID                            = 1
       LANGUAGE                      = 2
       NAME                          = 3
       NOT_FOUND                     = 4
       OBJECT                        = 5
       REFERENCE_CHECK               = 6
       WRONG_ACCESS_TO_ARCHIVE       = 7
       OTHERS                        = 8
    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 i_lines INTO wa_lines.
      WRITE: /1 wa_lines-tdline.
    ENDLOOP.
    Just execute this code by inputting ur material number.
    If the text doesnot exist the error u r getting because of not commenting the MESSAGE statement after FM call. Try in the way i told above.
    Thanks,
    Vinod.
    Edited by: Vinod Reddy Vemuru on Feb 28, 2009 4:36 PM

  • Problem with long text

    Hi folks,
    iam uploading longtext in transaction KP06 in bdc programing using create_text.
    now my problem is if i pass selection criteria
    case 1:
    Vertion : N0
    fiscal year : 2007
    planner profile: CCPLAN4
    then the budeget plan data uploading successfully along with long text.
    case2: Vertion : N1
    in this case also everthing wrking fine
    case3: Vertion : 001
    in this case budgetplan data uploading sucessfully but longtext is not uploading,
    i debbug the proragm , create_text also returning sy-subrc = 0. but if i check in KP06  the long text is not there.
    data declaration
    vertion : VERSN type C(3)
    can u tell me the problem is in logic or with FM ?
    note : i checked with save_text also.
    regards
    neeru

    HI Naimesh,
    the FM Create_text internally contains both FMs save_text and commit_text,
    even i debug the FM in case of vertion N1, N0 and 001,
    all the cases sy-subrc = 0.
    code:
    CLEAR G_OBJNR.
    LOOP AT RECORD.
    COST = RECORD-BDC01.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = COST
        IMPORTING
          output = COST.
        CONCATENATE 'KS' p_kokrs record-bdc00 INTO g_objnr.
            SELECT SINGLE * FROM COSP WHERE OBJNR = g_objnr
                              AND GJAHR = P_GJAHR
                              AND VERSN = p_ver
                              AND KSTAR = COST.
      IF SY-SUBRC = 0.
          LEDNR = COSP-LEDNR.
          OBJNR = COSP-OBJNR.
          GJAHR = COSP-GJAHR.
          WRTTP = COSP-WRTTP.
          VERSN = COSP-VERSN.
          KSTAR = COSP-KSTAR.
          HRKFT = COSP-HRKFT.
          VRGNG = COSP-VRGNG.
          VBUND = COSP-VBUND.
          PARGB = COSP-PARGB.
          BEKNZ = COSP-BEKNZ.
          TWAER = COSP-TWAER.
    CONCATENATE LEDNR OBJNR INTO OBJNR.
    CONCATENATE OBJNR GJAHR INTO TNAME1 separated BY SPACE10.
    CONCATENATE TNAME1 WRTTP VERSN INTO TNAME2.
    CONCATENATE TNAME2 KSTAR INTO TNAME3 separated BY SPACE.
    CONCATENATE TNAME3 VRGNG INTO TNAME4 separated BY SPACE4.
    CONCATENATE TNAME4 BEKNZ INTO TNAME5 separated BY SPACE10.
    CONCATENATE TNAME5 TWAER INTO TNAME.
    I_THEAD-TDOBJECT = 'CCSS'.
    I_THEAD-TDID = 'COSP'.
    I_THEAD-TDNAME = TNAME.
    I_THEAD-TDSPRAS = 'E'.
    APPEND I_THEAD.
    i_tline-tdformat = '*'.
    I_TLINE-TDLINE = RECORD-LONGTEXT.
    APPEND I_TLINE.
    loop at i_thead.
    CALL FUNCTION 'CREATE_TEXT'
      EXPORTING
        FID               = I_THEAD-TDID
        FLANGUAGE         = I_THEAD-TDSPRAS
        FNAME             = I_THEAD-TDNAME
        FOBJECT           = I_THEAD-TDOBJECT
      SAVE_DIRECT       = 'X'
      FFORMAT           = '*'
      TABLES
        FLINES            = i_tline
    EXCEPTIONS
      NO_INIT           = 1
      NO_SAVE           = 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.
    ENDLOOP.
    CLEAR I_TLINE.
    REFRESH I_TLINE.
    CLEAR I_THEAD.
    REFRESH I_THEAD.
      SELECT SINGLE * from cokp into itab WHERE OBJNR = g_objnr
                              AND GJAHR = P_GJAHR
                              AND VERSN = p_ver
                              AND KSTAR = COST.
    if sy-subrc = 0.
       itab-TXFLG = 'X'.
       append itab.
       write:/ 'Text saved for', record-bdc00 , record-bdc01.
       else.
          write:/ 'Text saved for', record-bdc00 , record-bdc01.
          ENDIF.
    ENDIF.
    my program wrking fine but the long text is not visible for vertion 001.
    regards
    niru

  • Problem in uploading multiple line items while Creating sales order by BAPI

    Hi experts ,  Im able to create sales order  with one item while using this program, but the problem is  when iam having multiple  items or multiple sales order  , iam not able to createthe line items , though its creating  sales order header , Iam copy pasting my code , please add the additional code to my code to take more than 1 line items ,This is urgent requirement . Points will be rewarded for answers , Thanks in advance
    *& Report  Z_SO_CREATE_BAPI
    REPORT  Z_SO_CREATE_BAPI.
    DATA: i_header TYPE bapisdhd1 occurs 0 with header line.
    DATA: i_details TYPE bapisditm OCCURS 0 WITH HEADER LINE.
    DATA: i_partner TYPE bapiparnr OCCURS 0 WITH HEADER LINE.
    DATA: i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: i_return2 TYPE bapiret2.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with HEADER LINE .
    data : ORDER_ITEMS_INX Like BAPISDITMX occurs 0 with HEADER LINE .
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LiNE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : ORDER_SCHEDULES_INX like BAPISCHDLX occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
           SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
           PURCH_DATE(10),
           PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
           PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
           ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
           TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
           ITM_NUMBERX like  ORDER_ITEMS_INX-ITM_NUMBER ,
           MATERIALX   LIKE  ORDER_ITEMS_INX-MATERIAL ,
           CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
           PLANTX LIKE ORDER_ITEMS_INX-PLANT,
           TARGET_QTYX LIKE ORDER_ITEMS_INX-TARGET_QTY,
           ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
           MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    DATA: v_vbeln TYPE bapivbeln-vbeln.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                     = p_infile
       FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = tab.
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    **Validation for the Create SO screen
    *AT SELECTION-SCREEN ON BLOCK na_create.
    Loop at Tab.
    i_header-doc_type =  TAB-DOC_TYPE .
    i_header-sales_org = TAB-SALES_ORG.
    i_header-distr_chan = TAB-DISTR_CHAN .
    i_header-division = TAB-DIVISION .
    append i_header.
    *endloop.
    i_partner-partn_role = TAB-PARTN_ROLE .
    i_partner-partn_numb =  TAB-PARTN_NUMB.
    APPEND i_partner.
    i_details-material =  TAB-MATERIAL .
    APPEND i_details.
    endloop.
    *Bapi for Creating SO
                   CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
                     EXPORTING
                     SALESDOCUMENTIN               = v_vbeln
                       order_header_in               = i_header
                     ORDER_HEADER_INX              =
                     SENDER                        =
                     BINARY_RELATIONSHIPTYPE       =
                     INT_NUMBER_ASSIGNMENT         =
                     BEHAVE_WHEN_ERROR             =
                     LOGIC_SWITCH                  =
                     TESTRUN                       =
                     CONVERT                       = ' '
                    IMPORTING
                      SALESDOCUMENT                 = v_vbeln
                     tables
                      RETURN                        = i_return1
                      ORDER_ITEMS_IN                = i_details
                      ORDER_ITEMS_INX               = ORDER_ITEMS_INX
                       order_partners                = i_partner .
                     ORDER_SCHEDULES_IN            =
                     ORDER_SCHEDULES_INX           =
                     ORDER_CONDITIONS_IN           =
                     ORDER_CONDITIONS_INX          =
                     ORDER_CFGS_REF                =
                     ORDER_CFGS_INST               =
                     ORDER_CFGS_PART_OF            =
                     ORDER_CFGS_VALUE              =
                     ORDER_CFGS_BLOB               =
                     ORDER_CFGS_VK                 =
                     ORDER_CFGS_REFINST            =
                     ORDER_CCARD                   =
                     ORDER_TEXT                    =
                     ORDER_KEYS                    =
                     EXTENSIONIN                   =
                     PARTNERADDRESSES              =
    IF NOT v_vbeln IS INITIAL.
    *Bapi Commit Work
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    return = i_return2
    ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    IMPORTING
    RETURN =
    ENDIF.
    LOOP AT i_return1 .  "INTO wa_return1.
    WRITE:/ i_return1-message.
    ENDLOOP.
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      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.
    txt file data
    order type  salesorg   distch      divison       materialno                  parter role
    TA     PB01     01     00     000000000000000852     WE
    Partner no
    8101000000

    Hi Neerja,
    you can reffer this sample code. It may not be complet soluation for your poblem,
    but you will get some idea.
    *& Report  ZBAPI_SALESORDER_CREATE
    *& Author : Karthik
    REPORT  ZBAPI_SALESORDER_CREATE.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
    header line.
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LINE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
            SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
            PURCH_DATE(10),
            PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
            PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
            ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
            TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    data: itab1 like alsmex_tabline occurs 0 with header
    line.
    DATA: gd_currentrow type i.
    data : PURCHASEORDER like ekko-ebeln.
    Data: tot_rec type i,     "Total Records
         gd_update type i,   "Main Table Increement Counter
         gd_lines type i,    "Success Table increement Counter
         w_textout like t100-text. "VARIABLE TO GET ERRORLOG
    data : begin of it_success occurs 0,
            SALESDOCUMENT LIKE BAPIVBELN-VBELN,  "PROJECT
          end of it_success.
    data : begin of it_error occurs 0,
            srno(4),
            err_msg(73) TYPE c,    "TO RETREIVE ERROR MESSAGES
         end of it_error.
    data : srno(4).
    DATA : SALESDOCUMENT LIKE  BAPIVBELN-VBELN.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_infile
          i_begin_col             = '1'
          i_begin_row             = '2' "Do not require
    headings
          i_end_col               = '22'
          i_end_row               = '10000'
        TABLES
          intern                  = itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          others                  = 3.
      if sy-subrc <> 0.
        message e010(zz) with text-001. "Problem uploading
    Excel Spreadsheet
      endif.
    *perform open_group.
      sort itab1 by row col.
    Get first row retrieved
      read table itab1 index 1.
    Set first row retrieved to current row
      gd_currentrow = itab1-row.
      loop at itab1.
    Reset values for next row
        if itab1-row ne gd_currentrow.
          append tab .
          clear tab.
          gd_currentrow = itab1-row.
        endif.
        SHIFT ITAB1-VALUE LEFT DELETING LEADING SPACE.
        case itab1-col.
          when '0001'.
            TAB-SRNO = itab1-value.
          when '0002'.
            TAB-DOC_TYPE = itab1-value.
          when '0003'.
            TAB-SALES_ORG = itab1-value.
          when '0004'.
            TAB-DISTR_CHAN = itab1-value.
          when '0005'.
            TAB-DIVISION = itab1-value.
         when '0006'.
           TAB-REQ_DATE_H =  itab1-value.
          when '0006'.
            TAB-PURCH_DATE = itab1-value.
          when '0007'.
            TAB-PMNTTRMS = itab1-value.
          when '0008'.
            TAB-PURCH_NO_C = itab1-value.
            when '0009'.
            TAB-ITM_NUMBER = itab1-value.
           when '0010'.
            TAB-CUST_MAT22 = itab1-value.
          when '0011'.
            TAB-PLANT  = itab1-value.
          when '0012'.
            TAB-TARGET_QTY = itab1-value.
          when '0013'.
            TAB-PARTN_ROLE = itab1-value.
          when '0014'.
            TAB-PARTN_NUMB = itab1-value.
        endcase.
      endloop.
      append tab.
      clear tab.
      sort tab by SRNO.
      LOOP AT TAB.
       concatenate tab-REQ_DATE_H+4(4)
    tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
    tab-REQ_DATE_H.
        concatenate tab-PURCH_DATE+4(4)
    tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
    tab-PURCH_DATE.
        SRNO = TAB-SRNO.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-PARTN_NUMB
          IMPORTING
            OUTPUT = tab-PARTN_NUMB.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-CUST_MAT22
          IMPORTING
            OUTPUT = tab-CUST_MAT22.
        IF TAB-SRNO = SRNO.
          ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
          ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
          ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
         ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
          ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
          ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
          ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
          ORDER_HEADER_IN-DIVISION  = tab-DIVISION.
          ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
          ORDER_ITEMS_IN-PLANT      = TAB-PLANT.
          APPEND ORDER_ITEMS_IN.
          ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
          ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
          APPEND ORDER_PARTNERS.
          ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
          append ORDER_SCHEDULES_IN.
        ENDIF.
        AT END OF SRNO.
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
               SALESDOCUMENTIN               =
                 ORDER_HEADER_IN               = ORDER_HEADER_IN
               ORDER_HEADER_INX              =
               SENDER                        =
               BINARY_RELATIONSHIPTYPE       =
               INT_NUMBER_ASSIGNMENT         =
               BEHAVE_WHEN_ERROR             =
               LOGIC_SWITCH                  =
               TESTRUN                       =
               CONVERT                       = ' '
           IMPORTING
             SALESDOCUMENT                 = SALESDOCUMENT
            TABLES
             RETURN                        = RETURN
                 ORDER_ITEMS_IN                = ORDER_ITEMS_IN
               ORDER_ITEMS_INX               =
                 ORDER_PARTNERS                = ORDER_PARTNERS
                 ORDER_SCHEDULES_IN            = ORDER_SCHEDULES_IN
               ORDER_SCHEDULES_INX           =
               ORDER_CONDITIONS_IN           =
               ORDER_CONDITIONS_INX          =
               ORDER_CFGS_REF                =
               ORDER_CFGS_INST               =
               ORDER_CFGS_PART_OF            =
               ORDER_CFGS_VALUE              =
               ORDER_CFGS_BLOB               =
               ORDER_CFGS_VK                 =
               ORDER_CFGS_REFINST            =
               ORDER_CCARD                   =
               ORDER_TEXT                    =
             ORDER_KEYS                    = ORDER_KEYS
               EXTENSIONIN                   =
               PARTNERADDRESSES              =
          IF SALESDOCUMENT <> SPACE.
            commit work.
            ADD 1 TO gd_update.
            it_success-SALESDOCUMENT = SALESDOCUMENT.
            append it_success.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ELSE.
            loop at return.
              it_error-SRNO = tab-SRNO.
              it_error-err_msg = return-MESSAGE .
              Append it_error.
            ENDLOOP.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ENDIF.
        endat.
      endloop.
      DESCRIBE TABLE it_success LINES gd_lines.
      IF gd_lines GT 0.
        Display result report column headings
        PERFORM display_column_headings.
        Display result report
        PERFORM DISPLAY_SUCESS.
      ENDIF.
    IF SUCESS FAILS Display Error Report
      DESCRIBE TABLE it_error LINES gd_lines.
      IF gd_lines GT 0.
        PERFORM errorheadings.
        PERFORM errorreport.
      ENDIF.
    *&      Form  display_column_headings
          text
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records inserted
    successfully:'(013).
      WRITE:/ sy-uline(15).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
               (10) 'Sales order'(004), sy-vline.
      WRITE:/ sy-uline(15).
    ENDFORM.                    "display_column_headings
    *Subroutine to display SUCESS REPORT
    FORM DISPLAY_SUCESS.
      FORMAT COLOR COL_NORMAL.
      LOOP AT it_success.
        WRITE:/      sy-vline,
            (10)  it_success-SALESDOCUMENT, sy-vline.
        CLEAR it_success.
      ENDLOOP.
      WRITE:/ sy-uline(15).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                               "
    DISPLAY_REPORT
    *&      Form  errorreport
          text
    FORM errorreport.
      LOOP AT it_error.
        WRITE:/      sy-vline,
                (10) it_error-SRNO, sy-vline,
                 (40) it_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    endform.                    "errorreport
    *&      Form  ERRORHEADINGS
          text
    FORM ERRORHEADINGS.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during
    update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'ERROR.'(009), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    "ERRORHEADINGS
    **&      Form  value_help
          text
    -->  p1        text
    <--  p2        text
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      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.                    "value_help
    Regards,
    Amit.

  • Problem while changing Sales order using 'BAPI_SALESORDER_CHANGE'

    Hi all,
    Below is my code to update delivery block value:
    FORM call_bapi_salesorder_change .
    DATA:  iv_bapi_view  LIKE order_view.
    DATA: gt_sales_doc TYPE STANDARD TABLE OF sales_key, " Document Numbers to Be Selected
            gt_items TYPE STANDARD TABLE OF bapisdit. " Order Item Data for Document Numbers
    *************************************************************8
    DATA:order_headers_out LIKE bapisdhd OCCURS 0 WITH HEADER LINE.
    DATA:order_header_inx LIKE bapisdh1x.
      DATA: lv_salesdocument LIKE bapivbeln-vbeln.
      data: lv_matnr(10) type c.
      DATA:
    gt_schdule TYPE STANDARD TABLE OF bapischdl, " for gl date & load date
    gt_schdulex TYPE STANDARD TABLE OF bapischdlx, " for partner role and partner function.
            gt_return TYPE STANDARD TABLE OF bapiret2,
            gt_itemin TYPE STANDARD TABLE OF bapisditm,
            gt_iteminx TYPE STANDARD TABLE OF bapisditmx ,
            gt_bapisdh1 TYPE STANDARD TABLE OF  bapisdh1.
      DATA:gs_head_bapi TYPE bapisdh1x,
           gs_schdule TYPE bapischdl,
           gs_schdulex TYPE bapischdlx,
           gs_return TYPE bapiret2,
           gs_itemin TYPE bapisditm,
           gs_iteminx TYPE bapisditmx,
           gs_bapisdh1 TYPE bapisdh1.
      CLEAR : gt_schdule,gt_schdulex,gs_return.
      REFRESH gt_return.
      gs_head_bapi-updateflag = 'U'.
    SORT gt_final BY vbeln.
    CLEAR gs_vbep.
    REFRESH gt_vbep[].
      CLEAR gs_final.
      LOOP AT gt_final1 INTO gs_final.
        gs_itemin-itm_number = gs_final-posnr.
    *move gs_final-matnr to lv_matnr."qx94162
       gs_itemin-material = gs_final-matnr.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = gs_final-matnr
          IMPORTING
            output = gs_final-matnr.
       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = lv_matnr
        IMPORTING
         output = lv_matnr.
       gs_itemin-material = lv_matnr.
        gs_itemin-material = gs_final-matnr.
        gs_iteminx-itm_number = gs_final-posnr.
        gs_iteminx-updateflag = 'U'.""changed to I
        gs_iteminx-material = 'X'.
        " gs_schdule-req_dlv_bl = gs_final-lifsp. " Delivery block
        gs_schdule-itm_number = gs_final-posnr.
        gs_schdulex-itm_number = gs_final-posnr.
        gs_schdule-sched_line = '0001'.
        gs_schdulex-sched_line = '0001'.
       MOVE gs_final-lifsp to gs_schdule-req_dlv_bl.
        gs_schdule-req_dlv_bl = gs_final-lifsp.
        gs_schdulex-req_dlv_bl = 'X'. " Delivery block
        gs_schdulex-updateflag = 'U'.
        gs_bapisdh1-sales_org = gs_final-vkorg.
        APPEND gs_schdule TO gt_schdule.
        APPEND gs_schdulex TO gt_schdulex.
        APPEND gs_itemin TO gt_itemin.
        APPEND gs_iteminx TO gt_iteminx.
       Append gs_BAPISDH1 to gt_BAPISDH1.
        lv_salesdocument = gs_final-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument               = lv_salesdocument     
           ORDER_HEADER_IN             = gs_BAPISDH1
            order_header_inx            = gs_head_bapi         
      SIMULATION                  =
      BEHAVE_WHEN_ERROR           = ' '
      INT_NUMBER_ASSIGNMENT       = ' '
      LOGIC_SWITCH                =
      NO_STATUS_BUF_INIT          = ' '
          TABLES
            return                      = gt_return            
       order_item_in               =    gt_itemin
       order_item_inx              = gt_iteminx
      PARTNERS                    =
      PARTNERCHANGES              =
      PARTNERADDRESSES            =
      ORDER_CFGS_REF              =
      ORDER_CFGS_INST             =
      ORDER_CFGS_PART_OF          =
      ORDER_CFGS_VALUE            =
      ORDER_CFGS_BLOB             =
      ORDER_CFGS_VK               =
      ORDER_CFGS_REFINST          =
          schedule_lines                = gt_schdule           
          schedule_linesx               = gt_schdulex          
      ORDER_TEXT                  =
      ORDER_KEYS                  =
      CONDITIONS_IN               =
      CONDITIONS_INX              =
      EXTENSIONIN                 =
      NFMETALLITMS                =
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        REFRESH: gt_schdule, gt_schdulex, gt_itemin , gt_iteminx.
        LOOP AT gt_return INTO gs_return.
          WRITE / gs_return-message .
        ENDLOOP .
      ENDLOOP.
    ENDFORM.                    " CALL_BAPI_SALESORDER_CHANGE
    When I am using material value as 18342 using CONVERSION_EXIT_ALPHA_OUTPUT:
    ORDER_HEADER_IN has been processed successfully
    Material  is not defined for sales org.A101,  distr.chan.00,  language DE
    Error in ITEM_IN 000030
    SCHEDULE_IN has been processed successfully
    The sales document is not yet complete: Edit data
    Sales document 5010000715 was not changed
    and when I am using CONVERSION_EXIT_ALPHA_INPUT (000000000000018342)or  while debuging when I am changing value to  0018342 :
    I am getting below dump:
    Runtime Errors         DATA_LENGTH_0
    Exception              CX_SY_RANGE_OUT_OF_BOUNDS
    Date and Time          21.10.2010 07:22:17
    Information on where terminated
         Termination occurred in the ABAP program "SAPLVBAK" - in
          "MAP_VBAP_TO_BAPISDIT".
         The main program was "RS_TESTFRAME_CALL ".
         In the source code you have the termination point in line 168
         of the (Include) program "LVBAK001".
         The termination is caused because exception "CX_SY_RANGE_OUT_OF_BOUNDS"
          occurred in
         procedure "MAP_VBAP_TO_BAPISDIT" "(FORM)", but it was neither handled local
          nor declared
         in the RAISING clause of its signature.
         The procedure is in program "SAPLVBAK "; its source code begins in line
         99 of the (Include program "LVBAK001 ".
    The same dump I am getting while executing this above BAPI from SE37 tcode with the same test data.
    but I am able to change it though Va02 tcode.
    Edited by: Arora26 on Oct 21, 2010 7:58 AM

    Hi,
    have you searched for OSS notes? The note 1137897 looks like related to your problem. It mentions different BAPI but I assume that both BAPI reuse same routines and therefore it might solve your problem as well.
    Cheers

  • Problem with select query

    Hi All,
    i_dfkkko-xblnr
      IF NOT i_dfkkko[] IS INITIAL       .
        SELECT opbel
               belnr
               FROM erchc
               INTO TABLE i_erchc1
               FOR ALL ENTRIES IN i_dfkkko
               WHERE opbel EQ i_dfkkko-xblnr.
      ENDIF.
    I am using the above select query.problem is when i put the value
    of i_dfkkko-xblnr by going to the table erchc i am getting the record.But this qury is not resulting any value.
    i have checked in debug mode copied the value of xblnr of i_dfkkko
    and went to erchc table and passed to opbel of erchc i got the reords.
    can anybody pls help..
    Rgds,
    Sai

    Hi,
    The database would be having the value with leading zeroes.
    Use FM "CONVERSION_EXIT_ALPHA_INPUT" to conver the values & then pass to select query.
    _dfkkko-xblnr
    IF NOT i_dfkkko[] IS INITIAL .
    loop at i_dfkkko.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    VALUE(INPUT) = i_dfkkko-xblnr
    IMPORITNG
    VALUE(OUTPUT) = i_dfkkko-xblnr.
    modify i_dfkkko.
    endloop.
    SELECT opbel
    belnr
    FROM erchc
    INTO TABLE i_erchc1
    FOR ALL ENTRIES IN i_dfkkko
    WHERE opbel EQ i_dfkkko-xblnr.
    ENDIF.

  • Problem with Leading Zeros

    Hi Experts,
    In the start routine, I  am trying to compare  two object 0PLANT and ZSTORE which  contains the same values. But the problem is 0PLANT is of length 4 and ZSTORE is of length 8. As a result,for example,  the value 2  in  0PLANT is stored as '0002' and as ' 00000002'  in ZSTORE.
      I have written the code as following, which is not working due to the leading ZEROES. Please note that Both objects don't have ALPHA conversion as part of the info Object Definition.
    *Select PLANT /BIC/CBRCH_GRP from /BI0/PPLANT into table I_PLNT
    where PLANT = DATA_PACKAGE-/BIC/ZSTORE.*
    Though I knew that there is a FM CONVERSION_EXIT_ALPHA_OUTPUT, I am not sure whether we can use that FM for procesisng bulk amount of data.
    Request you all to propose a solution for the same.
    Thanks in advance,
    Babu Vasamsetti.

    Hi Babu ,
    Please use the code below.
    You can modify it according to your requirements :
    TYPES: BEGIN OF TY_ZTORE,
            ZTORE TYPE /BIC/OIZTORE
            PLANT TYPE /BI0/OIPLANT,
           END OF TY_ZTORE.
    DATA:       LT_ZTORE TYPE STANDARD TABLE OF TY_ZTORE,
          LS_ZTORE TYPE TY_ZTORE.
    SELECT /BIC/ZSTORE FROM
    /BIC/PZSTORE INTO TABLE LT_ZTORE
    FOR ALL ENTRIES IN DATA_PACKAGE.
    SORT LT_PLANT BY /bic/ZTORE.
    DELETE ADJACENT DUPLICATES FROM LT_DATAPACKAGE COMPARING /BIC/ZSTORE.
    LOOP AT LT_ZTORE
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT         = LT_ZTORE-/BIC/ZSTORE
       IMPORTING
         OUTPUT        = LT_ZTORE-PLANT.
    ENDLOOP.
    Select PLANT /BIC/CBRCH_GRP from /BI0/PPLANT into table I_PLNT
    where PLANT = LT_STORE-PLANT.
    -Vikram

  • Purchase Order Problem

    HI Experts,
      I have copied a purchase order form ZMEDRUCK from Medruck.  Modified according to the requirements of functional consultant without deleting a single element.  I have commented everything in the windows except /E - element lines.  Used subroutines to fetch some data and displayed.  Its working normally, but when enduser is trying to generate a PO with some JPY currency, it is not giving print preview nor print. 
    In the subroutine pool for calculating grand total I have used the following code.
    FORM freight TABLES   TA_INPUT STRUCTURE ITCSY
                            TA_OUTPUT STRUCTURE ITCSY.      "Structure
      DATA: TP_FREIGHT LIKE KONV-KAWRT,  " freight charges
            TP_CUSTOMS LIKE KONV-KAWRT,  " customs charges
            TP_EBELN   LIKE EKKO-EBELN,  " PO number
            TP_KNUMV   LIKE EKKO-KNUMV,  " document condition number
            TP_GTOTAL  TYPE P DECIMALS 2,  " grand total
            TP_TOTAL   LIKE KONV-KAWRT. " like konv-kawrt  " total before freight and customs.
      DATA: lv_grandtot(16),             " TYPE P DECIMALS 2,
                                       " lv_grandtot type konv-kawrt,
            tp_total1(16),
            tp_waers like ekko-waers.
      DATA : IT_KONV LIKE KONV OCCURS 0 WITH HEADER LINE. " for condition values.
      read table TA_INPUT with key 'EKKO-EBELN'.
      TP_EBELN = TA_INPUT-VALUE.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = TP_EBELN
        IMPORTING
          OUTPUT = TP_EBELN.
      READ TABLE TA_INPUT WITH KEY 'KOMK-FKWRT'.
    **without this function module, getting short dump while adding for grand total.
    **CONDENSE TA_INPUT-VALUE.
    *MOVE TA_INPUT-VALUE TO TP_TOTAL.
      CALL FUNCTION 'CATS_ITS_MAKE_STRING_NUMERICAL'
        EXPORTING
          INPUT_STRING  = TA_INPUT-VALUE
        IMPORTING
          VALUE         = TP_TOTAL
        EXCEPTIONS
          NOT_NUMERICAL = 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.
    READ TABLE TA_INPUT WITH KEY 'EKKO-WAERS'.
    tp_waers = ta_input-value.
    if tp_waers = 'JPY'.
    tp_total = tp_total * 10.
    endif.
    WRITE: TP_TOTAL TO TP_TOTAL1 CURRENCY 'JPY' LEFT-JUSTIFIED.
      SELECT SINGLE KNUMV FROM EKKO INTO TP_KNUMV WHERE EBELN = tp_ebeln.
      SELECT * FROM KONV INTO TABLE IT_KONV WHERE KNUMV = TP_KNUMV
                                          AND KSCHL IN ('FRB1' , 'ZOB1').
    *BREAK-POINT.
      LOOP AT IT_KONV.
        CASE IT_KONV-KSCHL.
          WHEN 'FRB1'.
            TP_FREIGHT = TP_FREIGHT + IT_KONV-KBETR.
          WHEN 'ZOB1'.
            TP_CUSTOMS = TP_CUSTOMS + IT_KONV-KBETR.
        ENDCASE.
      ENDLOOP.
    *******grand total.
    ***here if don't use function module CATS_ITS_MAKE_STRING_NUMERICAL, I get short dump.
      TP_GTOTAL = TP_TOTAL + TP_FREIGHT + TP_CUSTOMS.
    *WRITE TP_GTOTAL TO lv_grandtot CURRENCY tp_waers DECIMALS 2 LEFT-JUSTIFIED.
    WRITE TP_GTOTAL TO lv_grandtot CURRENCY tp_waers LEFT-JUSTIFIED.
    *move tp_gtotal to lv_grandtot.
      loop at TA_OUTPUT.
        case TA_OUTPUT-NAME.
          when 'TP_FREIGHT'.
            MOVE TP_FREIGHT TO TA_OUTPUT-VALUE  .
            CONDENSE TA_OUTPUT-VALUE.
            modify TA_OUTPUT.
          when 'TP_CUSTOMS'.
            MOVE TP_CUSTOMS TO TA_OUTPUT-VALUE  .
            CONDENSE TA_OUTPUT-VALUE.
            modify TA_OUTPUT.
          when 'TP_GTOTAL'.
            MOVE lv_grandtot TO TA_OUTPUT-VALUE  .
            CONDENSE TA_OUTPUT-VALUE.
            modify TA_OUTPUT.
        endcase.
      endloop.
    endform.                    "freight
    It is working well even with JPY currency, but this time when she was entering a material with JPY currency, neither preview is coming nor print.  In the status bar(in me21n) it shows error that a certain include is not available, but when I enter into script debugging mode, print preview is coming and grand total is 0, because of error in function module.  In the ABAP debugging mode, in the function module I have used, the sy-subrc is 1.  This is go-live issue and this problem has occurred in Prod server.  We could not stimulate the scene in Dev server.
    In Dev, I noticed that when ever I tick off in 'Ret PO' check box, the same problem is coming.
    Can any one help me with this problem.

    The table PO_AGENTS stores the buyers .
    To define a buyer, you need to define an employee (Purchasing super user > Setup > Personnel > Employees), then a Buyer (Purchasing super user > Setup>Personnel > Buyers)

  • PR to PO ...Standard text problem

    Hi all,
    I am writing one report , which converts the purchasing requistion to purchase order. I am using the BAPI function module...BAPI_PO_CREATE1.
    In this i want to populate the purchase order header text. I am using the standard text for all po's whose are convertable.
    but the problem is , the header text table paramers(POTEXTHEADER) in BAPI FM will take 132 chars only. But my standard text is 6 paragraphs are there . how do i long text populate? Am i using the wrong parameters in the BAPI FM.
    please suggest me ...how to use this BAPI FM , to populate the lonf standard text.
    regards,
    Ajay Reddy
    Edited by: Ajay on May 27, 2008 9:08 AM

    hi
    use the function module create_text to upload long text. below is the
    sample program which uploads purchase order text more than 132 characters.
    TABLES : MARA, TLINE, THEAD.
    DATA: BEGIN OF ITAB OCCURS 0,
          MATNR LIKE MARA-MATNR, " MATERIAL  NUMBER
          TEXT(5000)  TYPE C, " Long Text
          END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0,
          MATNR LIKE MARA-MATNR, " Material  No
          SEQU  TYPE I,          " Text Sequence
          TEXT(5000)  TYPE C, " Long Text
          END OF ITAB1.
    DATA:BEGIN OF DT_LINES OCCURS 0.
            INCLUDE STRUCTURE TLINE. " Long Text
    DATA:END OF DT_LINES.
    DATA : P_FILE1 TYPE STRING.
    DATA : DL_NAME TYPE THEAD-TDNAME, " Object Name(material no)
           DL_LAN TYPE THEAD-TDSPRAS. " Language
    CONSTANTS:C_BEST TYPE THEAD-TDID VALUE 'BEST',
              C_MATERIAL TYPE THEAD-TDOBJECT VALUE 'MATERIAL'. " OBJECT
    DATA: START TYPE I,
          LEN   TYPE I VALUE 92,
          TOTLEN TYPE I,
          N TYPE I.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-101.
    PARAMETERS P_FILE LIKE RLGRAP-FILENAME."input file
    SELECTION-SCREEN : END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      PERFORM FETCH_FILE USING P_FILE.
    *&      Form  fetch_file
          text
         -->P_FILE     text
    FORM FETCH_FILE USING P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
        IMPORTING
          FILE_NAME     = P_FILE.
    ENDFORM.                    "fetch_file
    START-OF-SELECTION.
      PERFORM UPLOAD USING P_FILE. " *To Upload Flat file
      PERFORM UPLOAD_TEXT.
    *&      Form  UPLOAD
          text
         -->P_FILE     text
    FORM UPLOAD USING P_FILE.
      P_FILE1 = P_FILE.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = P_FILE1
         FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = ' '
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
        TABLES
          DATA_TAB                      = ITAB
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
      IF SY-SUBRC EQ 0.
    *message i001 with p_file .
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "UPLOAD
    *&      Form  UPLOAD_TEXT
          text
    FORM UPLOAD_TEXT.
      LOOP AT ITAB.
        ITAB1-MATNR = ITAB-MATNR.
        CLEAR: TOTLEN,N, START.
        TOTLEN = STRLEN( ITAB-TEXT ).
        N = TOTLEN / LEN.
        N = N + 1.
        DO N TIMES.
          ITAB1-TEXT  = ITAB-TEXT+START(LEN).
          ITAB1-SEQU  = SY-INDEX.
          START = START + LEN.
          APPEND ITAB1.
        ENDDO.
      ENDLOOP.
      DELETE ITAB1 WHERE TEXT IS INITIAL.
      SORT ITAB1 BY MATNR SEQU.
      LOOP AT ITAB1.
        DT_LINES-TDFORMAT = '*'.
        DT_LINES-TDLINE = ITAB1-TEXT.
        APPEND DT_LINES.
        AT END OF MATNR.
          DL_LAN = SY-LANGU.
            WRITE : / itab-MATNR.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              INPUT  = ITAB1-MATNR
            IMPORTING
              OUTPUT = ITAB1-MATNR.
          MOVE ITAB1-MATNR TO DL_NAME.
          CALL FUNCTION 'CREATE_TEXT'
            EXPORTING
              FID         = C_BEST
              FLANGUAGE   = DL_LAN
              FNAME       = DL_NAME
              FOBJECT     = C_MATERIAL
              SAVE_DIRECT = 'X'
              FFORMAT     = '*'
            TABLES
              FLINES      = DT_LINES
            EXCEPTIONS
              NO_INIT     = 1
              NO_SAVE     = 2
              OTHERS      = 3.
          IF SY-SUBRC <> 0.
            WRITE:/10  'Long Text Creation failed for Material No',  ITAB1-MATNR.
          ELSE.
            WRITE:/10 'Long Text Created Successfully for Material No', ITAB1-MATNR.
          ENDIF.
          REFRESH DT_LINES.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    "UPLOAD_TEXT

  • Problem with jest table

    Hi,
    I want featch the data in jast table by using for all entries of aufk table.
    But just table object number have 22 characters and aufk table order number is 12 characters.
    in just table object number value is stroed like this   '00000000or23456789123' . but aufk table have order nuber is '23456789123'.
    how to compare it both.
    please  any one tell that one.

    Hi Anitha,
    The best way to approach this problem is to append the leading spaces with 0's in the search field. Actually you need to convert the Char 12 field into char 22 field. Then only this will work. You can use the function module :
    CONVERSION_EXIT_ALPHA_INPUT. But again there are some other Alphabetic Values then you need to make the changes manually in the field. And then prepare the search string and pass it to the table for search.
    Hope this will help.
    Thanks,
    Samantak.

  • Problem i  report

    hi SDNs,
    i have problem with my report..
    thing is : in my selection-screen, there are screen elements like : werks, storage location, budat, material...etc.,
    if i give matnr,werks ,lgort, and date : the report is giving correct result. where as if i don't give storage location the output is giving less records...
    where could be the problem? can any one help me out??
    its very urgent...
    thanking you,
    Ramakrishna S

    hi all,
    my report:
    in this <b>zmmr_stockdetails_variables</b>  is include. this is after this code:
    INCLUDE: DATA DECLARATION / SELECTION-SCREEN / INITIALIZATION / SCREEN EVENTS
    include zmmr_stockdetails_variables .
    START-OF-SELECTION
    start-of-selection.
      perform fr_start_of_selection.
    *&      Form  fr_start_of_selection
    form fr_start_of_selection .
      data:   lt_doc   type  tt_doc,
              lt_ser03 type  tt_ser03,
              lt_objk  type  tt_objk,
              lt_final type  tt_final,
              lt_ftp   type  tt_ftp,
              lt_equi  type  tt_equi,
              lt_doc_temp type tt_doc_temp.
      perform fr_get_material_doc_data changing lt_doc
                                                lt_doc_temp
                                                lt_ser03
                                                lt_objk
                                                lt_equi.
      if ( lt_doc[] is not initial ) and ( lt_objk[] is not initial ).
        perform fr_final_output_data using    lt_objk
                                              lt_doc
                                              lt_doc_temp
                                     changing lt_final
                                              lt_ftp.
      endif.
      if p_ftp = 'X' and ( lt_ftp is not initial ).
    *--Send data to FTP
        perform ftp_data using lt_ftp.
      elseif ( lt_final is not initial ).
    *--Display data in ALV with SUBTOTAL
        perform fr_display_data using lt_final.
      elseif ( lt_final is initial ).
    *--Display NO DATA
        perform fr_display_no_data .
      endif.
    endform.                    " fr_start_of_selection
    *&      Form  fr_get_material_doc_data
    form fr_get_material_doc_data  changing lt_doc      type tt_doc
                                            lt_doc_temp type tt_doc_temp
                                            lt_ser03    type tt_ser03
                                            lt_objk     type tt_objk
                                            lt_equi     type tt_equi.
      data : lw_doc    type tw_doc,
             lw_doc_temp type tw_doc_temp,
             lw_ser03  type tw_ser03,
             lw_objk   type tw_objk,
             lw_objk1  type tw_objk,
             lt_objk1  type tt_objk,
             lw_equi   type tw_equi.
      if p_ftp = 'X'.
        if s_cpudt is initial.
          s_cpudt-sign = 'I'.
          s_cpudt-option = 'EQ'.
          s_cpudt-low = sy-datum - 1.
          append s_cpudt.
        endif.
      endif.
    IF s_lgort[] IS NOT INITIAL.
       SELECT  a~mblnr
               a~mjahr
               a~zeile
               a~bwart
               a~matnr
               a~werks
               a~lgort
               a~shkzg
               a~bwtar
               a~ebeln
               a~ps_psp_pnr
               b~budat
               a~equnr                                         "MOD-001
          FROM mseg AS a JOIN mkpf AS b
          ON  amblnr = bmblnr AND
              amjahr = bmjahr
          INTO TABLE lt_doc
          WHERE a~matnr IN s_matnr AND
                a~sobkz IN s_sobkz AND
                a~werks EQ p_werks AND
                a~lgort IN s_lgort AND
                a~bwtar IN s_bwtar AND
                b~budat IN s_budat AND
                b~cpudt IN s_cpudt AND
                a~bwart IN s_bwart .
    ELSE.
      select  a~mblnr
              a~mjahr
              a~zeile
              a~bwart
              a~matnr
              a~werks
              a~lgort
              a~shkzg
              a~bwtar
              a~ebeln
              a~ps_psp_pnr
              b~budat
              a~equnr                                           "MOD-001
         from mseg as a join mkpf as b
         on  amblnr = bmblnr and
             amjahr = bmjahr
         into table lt_doc
         where a~matnr in s_matnr and
               a~sobkz in s_sobkz and
               a~werks eq p_werks and
               a~lgort in s_lgort and
               a~bwtar in s_bwtar and
               b~budat in s_budat and
               b~cpudt in s_cpudt and
               a~bwart in s_bwart .
    ENDIF.
      if ( lt_doc[] is not initial ).
        select obknr
               mblnr
               mjahr
               zeile
               bwart
               datum
               uzeit
               anzsn
               werk
               lagerort
          from ser03
          into table lt_ser03
          for all entries in lt_doc
          where mblnr = lt_doc-mblnr    and
                mjahr = lt_doc-mjahr    and
                zeile = lt_doc-zeile    and
                werk  = lt_doc-werks    and
                lagerort = lt_doc-lgort .
      endif.
      if ( lt_ser03[] is not initial ).
        select obknr
               equnr
               sernr
               matnr
          from objk
          into table lt_objk1
          for all entries in lt_ser03
          where obknr = lt_ser03-obknr and
                matnr in s_matnr.
      endif.
      if ( lt_objk1[] is not initial ).
        select  equnr from equi
                into table lt_equi
                for all entries in lt_objk1
                where equnr = lt_objk1-equnr and
                      matnr = lt_objk1-matnr and
                      eqtyp in s_eqtyp.
      endif.
      sort lt_objk1 by obknr equnr.
      sort lt_equi  by equnr.
    *-Append all data to OBJK for the EQNR
      loop at lt_objk1 into lw_objk1.
        read table  lt_equi into lw_equi with key equnr = lw_objk1-equnr.
        if sy-subrc eq 0.
          append lw_objk1 to lt_objk.
          clear: lw_objk1, lw_equi.
        endif.
      endloop.
    *-Modify LT_DOC with Object list number(OBKNR) from SER03
      loop at lt_ser03 into lw_ser03.
        read table lt_doc into lw_doc with key  mblnr = lw_ser03-mblnr
                                                zeile = lw_ser03-zeile
                                                mjahr = lw_ser03-mjahr.
        if ( sy-subrc = 0 ) and ( lw_ser03-obknr is not initial ).
          lw_doc-obknr = lw_ser03-obknr.
          lw_doc-datum = lw_ser03-datum.
          lw_doc-uzeit = lw_ser03-uzeit.
          modify lt_doc from lw_doc transporting obknr datum uzeit where mblnr = lw_ser03-mblnr and
                                                                         zeile = lw_ser03-zeile and
                                                                         mjahr = lw_ser03-mjahr."#EC *
        endif.
        clear: lw_doc, lw_ser03.
      endloop.
    *-Modify LT_DOC_TEMP with (MBLNR / SERNR / BWART / TIME ) from SER03
      sort lt_objk by obknr.
      loop at lt_objk into lw_objk.
        read table lt_ser03 into lw_ser03 with key obknr = lw_objk-obknr.
        if ( sy-subrc = 0 ) .
          lw_doc_temp-mblnr = lw_ser03-mblnr.
          lw_doc_temp-mjahr = lw_ser03-mjahr.
          lw_doc_temp-sernr = lw_objk-sernr.
          lw_doc_temp-bwart = lw_ser03-bwart.
          lw_doc_temp-datum = lw_ser03-datum.
          lw_doc_temp-uzeit = lw_ser03-uzeit.
          lw_doc_temp-werk  = lw_ser03-werk.
          lw_doc_temp-plant = lw_ser03-lagerort.
          append lw_doc_temp to lt_doc_temp .
          clear: lw_doc_temp, lw_ser03, lw_objk .
        endif.
      endloop.
      sort lt_doc_temp by sernr.
    *--If EXTRA entries deleted as per LATEST DOC, then Comment this below line.
      delete adjacent duplicates from lt_doc_temp comparing sernr.
    *--End of - If EXTRA entries deleted as per LATEST DOC, then Comment this line.
    *Delete itab where OBKNR is initial.
      delete lt_doc[] where obknr = ' '.
      sort lt_doc[] by matnr werks.
      loop at lt_doc into lw_doc.
        if ( lw_doc-werks is not initial ).
          select name1
                 up to 1 rows
                 into lw_doc-name1
                 from t001w
                 where werks = lw_doc-werks.
          endselect.
        endif.
        if ( lw_doc-matnr is not initial ).
          select maktx
                 up to 1 rows
                 into lw_doc-maktx
                 from makt
                 where matnr = lw_doc-matnr.
          endselect.
        endif.
        if ( lw_doc-werks is not initial ) and
           ( lw_doc-lgort is not initial ).
          select agency
                 up to 1 rows
                 into lw_doc-agency
                 from zcrmtosap
                 where werks = lw_doc-werks and
                       lgort = lw_doc-lgort.
          endselect.
        endif.
        if ( lw_doc-name1 is not initial ) or ( lw_doc-maktx is not initial ) or
           ( lw_doc-agency is not initial ).
          modify lt_doc from lw_doc transporting name1 maktx agency ."#EC *
        endif.
        clear: lw_doc.
      endloop.
      sort lt_objk[] by obknr equnr.
    endform.                    " fr_get_data_from_mseg
    *&      Form  fr_final_output_data
    form fr_final_output_data using    lt_objk  type tt_objk
                                       lt_doc   type tt_doc
                                       lt_doc_temp type tt_doc_temp
                             changing  lt_final type tt_final
                                       lt_ftp   type tt_ftp.
      data :   lw_doc         type tw_doc,
               lw_doc_temp    type tw_doc_temp,
               lw_objk        type tw_objk,
               lw_final       type tw_final,
               lt_final_temp  type tt_final,
               lw_ftp         type tw_ftp,
               lf_mblnr       type mblnr,
               lf_sernr       type gernr,
               lf_final_sernr type gernr,
               lf_final_matnr type matnr,
               lf_doc_sernr   type gernr,
               lf_doc_matnr   type matnr,
               lf_bwart       type bwart,
               lf_count       type i,
               lf_mjahr       type mjahr,
               lf_maktx       type maktx,
               lf_budat       type budat,
               lf_uzeit       type uzeit,
               lf_ebeln       type bstnr,
               lf_werks       type werks_d,
               lf_name1       type name1,
               lf_lgort       type lgort_d,
               lf_shkzg       type shkzg,
               lf_agency      type sgtxt,
               lf_zeile       type mblpo,
               lf_obknr       type objknr,
               lf_bwtar       type bwtar,
               lf_psp         type ps_psp_pnr.
      sort lt_doc[]  by obknr.
      sort lt_objk[] by obknr.
    *-append FINAL table with all fields from OBJK / SER03 tables
      loop at lt_objk into lw_objk.
        read table lt_doc into lw_doc with key obknr = lw_objk-obknr.
        if sy-subrc = 0.
          lw_final-matnr       =    lw_doc-matnr.
          lw_final-sernr       =    lw_objk-sernr.
          lw_final-budat       =    lw_doc-budat.
          lw_final-uzeit       =    lw_doc-uzeit.
          lw_final-ebeln       =    lw_doc-ebeln.
          lw_final-werks       =    lw_doc-werks.
          lw_final-lgort       =    lw_doc-lgort.
          lw_final-mblnr       =    lw_doc-mblnr.
          lw_final-zeile       =    lw_doc-zeile.
          lw_final-obknr       =    lw_objk-obknr.
          lw_final-bwtar       =    lw_doc-bwtar.
          lw_final-ps_psp_pnr  =    lw_doc-ps_psp_pnr.
          lw_final-name1       =    lw_doc-name1.
          lw_final-maktx       =    lw_doc-maktx.
          lw_final-agency      =    lw_doc-agency.
          lw_final-bwart       =    lw_doc-bwart.
          lw_final-count       =    '1'.
          append lw_final to lt_final.
          clear: lw_final, lw_doc.
        endif.
      endloop.
    *-Modify FINAL table with Year / Debit-Credit Indicator
      if ( lt_final[] is not initial ) .
        loop at lt_final into lw_final.
          read table lt_doc into lw_doc with key mblnr = lw_final-mblnr
                                                 zeile = lw_final-zeile.
          if sy-subrc = 0.
            lw_final-mjahr = lw_doc-mjahr.
            lw_final-shkzg = lw_doc-shkzg.
            if ( lw_final-mjahr is not initial ) or ( lw_final-shkzg is not initial ).
              modify lt_final from lw_final transporting mjahr shkzg.
            endif.
            clear: lw_final, lw_doc.
          endif.
        endloop.
    *-Modify lt_doc FROM final table w.r.t ESN number
        loop at lt_doc into lw_doc.
          read table lt_final into lw_final with key mblnr = lw_doc-mblnr.
          if sy-subrc = 0.
            lw_doc-sernr = lw_final-sernr.
            if ( lw_doc-sernr is not initial ).
              modify lt_doc from lw_doc transporting sernr.
            endif.
            clear: lw_doc, lw_final.
          endif.
        endloop.
    *--Remove Preceding ZEROS from SERNR of LT_FINAL
        loop at lt_final into lw_final.
          clear: lf_final_sernr.
          call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
            exporting
              input  = lw_final-sernr
            importing
              output = lf_final_sernr.
          if ( lf_final_sernr is not initial ).
            lw_final-sernr = lf_final_sernr.
            modify lt_final from lw_final transporting sernr.
            clear: lw_final-sernr.
          endif.
    *--Remove Preceding ZEROS from MATNR of LT_FINAL
          clear: lf_final_matnr.
          call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
            exporting
              input  = lw_final-matnr
            importing
              output = lf_final_matnr.
          if ( lf_final_matnr is not initial ).
            lw_final-matnr = lf_final_matnr.
            modify lt_final from lw_final transporting matnr.
            clear: lw_final-matnr.
          endif.
        endloop.
    *--Remove Preceding ZEROS from SERNR of LT_DOC
        loop at lt_doc into lw_doc.
          clear: lf_doc_sernr.
          call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
            exporting
              input  = lw_doc-sernr
            importing
              output = lf_doc_sernr.
          if ( lf_doc_sernr is not initial ).
            lw_doc-sernr = lf_doc_sernr .
            modify lt_doc from lw_doc transporting sernr.
            clear: lw_doc-sernr.
          endif.
    *--Remove Preceding ZEROS from MATNR of LT_DOC
          clear: lf_doc_matnr.
          call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
            exporting
              input  = lw_doc-matnr
            importing
              output = lf_doc_matnr.
          if ( lf_doc_matnr is not initial ).
            lw_doc-matnr = lf_doc_matnr.
            modify lt_doc from lw_doc transporting matnr.
            clear: lw_doc-matnr.
          endif.
        endloop.
    *For given ESN select the first Material Document (Latest Document) from the sorted list,
    *check for the Movement type of that document and if the Movement type falls in any of
    *the following then remove the ESN and its Material Documents.
    *Movement types for which ESN needs to be deleted: 102,201,221,261,351,502,562,601,Y52,Z52
    *Consider the Debit / Credit Indicator (MSEG_SHKZG)= 'S' (ignore H) for the following
    *Movement Types. 311, 312, 313, 314, 352, 411, 412, 415, 416.
        sort lt_final[] descending by shkzg sernr budat uzeit  mblnr." MOD-01
        sort lt_doc[]   by bwart.
        loop at lt_final into lw_final.
          lf_sernr = lw_final-sernr.
          lf_mblnr = lw_final-mblnr.
          lf_budat = lw_final-budat.
          lf_uzeit = lw_final-uzeit.
          lf_ebeln = lw_final-ebeln.
          lf_werks = lw_final-werks.
          lf_name1 = lw_final-name1.
          lf_lgort = lw_final-lgort.
          lf_shkzg = lw_final-shkzg.
          lf_agency = lw_final-agency.
          lf_zeile = lw_final-zeile.
          lf_obknr = lw_final-obknr.
          lf_bwart = lw_final-bwart.
          lf_bwtar = lw_final-bwtar.
          lf_psp   = lw_final-ps_psp_pnr.
          lf_count = lw_final-count.
    *-For given ESN select the first Material Document (Latest Document)
          at new sernr.
            read table lt_doc into lw_doc with key mblnr = lf_mblnr
                                                   lgort = lf_lgort.
            if sy-subrc = 0.
              move lf_mblnr to lw_final-mblnr.
              move lf_sernr to lw_final-sernr.
              move lf_budat to lw_final-budat.
              move lf_uzeit to lw_final-uzeit.
              move lf_ebeln to lw_final-ebeln.
              move lf_werks to lw_final-werks.
              move lf_name1 to lw_final-name1.
              move lf_lgort to lw_final-lgort.
              move lf_shkzg to lw_final-shkzg.
              move lf_agency to lw_final-agency.
              move lf_zeile to lw_final-zeile.
              move lf_obknr to lw_final-obknr.
              move lf_bwart to lw_final-bwart.
              move lf_bwtar to lw_final-bwtar.
              move lf_psp   to lw_final-ps_psp_pnr.
              move lf_count to lw_final-count.
              append lw_final to lt_final_temp.
              clear: lw_final, lf_mblnr, lf_sernr, lf_budat, lf_ebeln, lf_werks, lf_name1, lf_shkzg,
                     lf_lgort, lf_agency, lf_zeile, lf_obknr, lf_bwart, lf_bwtar, lf_psp, lf_count.
            endif.
          endat.
        endloop.
        refresh: lt_final[].
        lt_final[] = lt_final_temp[].
        refresh: lt_final_temp[].
        if ( lt_final[] is not initial ) .
          sort lt_final[] by bwart.
    *Movement types for which ESN needs to be deleted: 102,201,221,261,351,502,562,601,Y52,Z52
          delete lt_final[] where ( ( bwart = '102' ) or ( bwart = '201' ) or ( bwart = '221' ) or
                                    ( bwart = '261' ) or ( bwart = '351' ) or ( bwart = '452' ) or
                                    ( bwart = '502' ) or ( bwart = '562' ) or ( bwart = '601' ) or
                                    ( bwart = 'Y52' ) or ( bwart = 'Z52' ) ).
          if ( lt_final[] is not initial ) .
    *Consider the Debit / Credit Indicator (MSEG_SHKZG)= 'S' (ignore H) for the following
    *Movement Types. 311, 312, 313, 314, 352, 411, 412, 415, 416.
            sort lt_final[] by bwart shkzg.
            delete lt_final[] where ( bwart = '311' and shkzg = 'H' ) or
                                    ( bwart = '312' and shkzg = 'H' ) or
                                    ( bwart = '313' and shkzg = 'H' ) or
                                    ( bwart = '314' and shkzg = 'H' ) or
                                    ( bwart = '352' and shkzg = 'H' ) or
                                    ( bwart = '411' and shkzg = 'H' ) or
                                    ( bwart = '412' and shkzg = 'H' ) or
                                    ( bwart = '415' and shkzg = 'H' ) or
                                    ( bwart = '416' and shkzg = 'H' ).
          endif.
        endif.
    *==================================================================================================
    *START OF MOD-01
    *Delete EXTRA entries, when the SAME ESN number is appearing for different MBLNR / Storage Location.
        sort lt_final by budat descending.
        sort lt_final by sernr .
        delete adjacent duplicates from lt_final comparing sernr.
        loop at lt_final into lw_final.
          clear lf_final_sernr.
          call function 'CONVERSION_EXIT_ALPHA_INPUT'
            exporting
              input  = lw_final-sernr
            importing
              output = lf_final_sernr.
          clear : lf_lgort, lf_werks.
          select  b_werk
                 into lf_werks
                 from eqbs
                 where equnr = lf_final_sernr .
            if sy-subrc = 0 .
            if ( lf_werks ne p_werks ).
              delete lt_final.
              endif.
            endif.
          endselect.
          if sy-subrc <> 0.
            delete lt_final.
          endif.
        endloop.
        if s_lgort[] is not initial.
          loop at lt_final into lw_final.
            clear lf_lgort.
            select b_lager
                   into lf_lgort
                   from eqbs
                   where equnr = lf_final_sernr .
              if ( lf_lgort not in s_lgort ) .
                delete lt_final.
              endif.
            endselect.
            if sy-subrc <> 0.
              delete lt_final.
            endif.
          endloop.
        endif.
        if s_budat[] is not initial.
          delete lt_final where budat not in s_budat.
        endif.
    *END OF MOD-01
    *============================================================================
        loop at lt_final into lw_final.
          concatenate lw_final-matnr ',' into lw_ftp-matnr.
          concatenate lw_final-sernr ',' into lw_ftp-sernr.
          concatenate lw_final-budat ',' into lw_ftp-budat.
          concatenate lw_final-ebeln ',' into lw_ftp-ebeln.
          concatenate lw_final-werks ',' into lw_ftp-werks.
          concatenate lw_final-lgort ',' into lw_ftp-lgort.
          concatenate lw_final-mblnr ',' into lw_ftp-mblnr.
          concatenate lw_final-bwtar ',' into lw_ftp-bwtar.
          concatenate lw_final-bwart ',' into lw_ftp-bwart.
          call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
            exporting
              input  = lw_final-ps_psp_pnr
            importing
              output = lw_ftp-ps_psp_pnr.
          concatenate lw_final-name1  ',' into lw_ftp-name1.
          concatenate lw_final-maktx  ',' into lw_ftp-maktx.
          concatenate lw_final-agency ',' into lw_ftp-agency.
          append lw_ftp to lt_ftp.
          x = x + 1.
          clear: lw_ftp, lw_final .
        endloop.
        sort lt_final[] descending by budat.
      endif.
    endform.                    " fr_final_output_data
    *&      Form  display_data
    form fr_display_data using lt_final type tt_final .
      data: lt_fieldcat type slis_t_fieldcat_alv.
      gf_repid = sy-repid.
      perform e01_fieldcat_init  changing lt_fieldcat[].
      perform eventtab_build     changing gt_events.
      perform e04_comment_build  using gt_list_top_of_page[].
      perform display_report     using lt_final
                                       lt_fieldcat.
    endform.                    " display_data
    *&      Form  e01_fieldcat_init
    form e01_fieldcat_init changing lt_fieldcat type slis_t_fieldcat_alv.
      data: ls_fieldcat type slis_fieldcat_alv,
            ls_sort     type slis_sortinfo_alv.                 "#EC *
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'MATNR'.
      ls_fieldcat-ref_fieldname  = 'MATNR'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'EKPO'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '1'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'MAKTX'.
      ls_fieldcat-ref_fieldname  = 'MAKTX'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MAKT'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '2'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'SERNR'.
      ls_fieldcat-ref_fieldname  = 'SERNR'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'OBJK'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '3'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'BUDAT'.
      ls_fieldcat-ref_fieldname  = 'BUDAT'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MKPF'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '4'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'EBELN'.
      ls_fieldcat-ref_fieldname  = 'EBELN'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'EKPO'.
      ls_fieldcat-key            = ' '.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '5'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'WERKS'.
      ls_fieldcat-ref_fieldname  = 'WERKS'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '6'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'LGORT'.
      ls_fieldcat-ref_fieldname  = 'LGORT'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '7'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'NAME1'.
      ls_fieldcat-ref_fieldname  = 'NAME1'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'T001W'.
      ls_fieldcat-seltext_l      = 'Plant Desc'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '8'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'AGENCY'.
      ls_fieldcat-ref_fieldname  = 'AGENCY'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'ZCRMTOSAP'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '9'.
      ls_fieldcat-seltext_l      = 'Dealer code'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'MBLNR'.
      ls_fieldcat-ref_fieldname  = 'MBLNR'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '10'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'BWART'.
      ls_fieldcat-ref_fieldname  = 'BWART'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '11'.
      ls_fieldcat-seltext_l      = 'Movement Type'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'BWTAR'.
      ls_fieldcat-ref_fieldname  = 'BWTAR'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '12'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'PS_PSP_PNR'.
      ls_fieldcat-ref_fieldname  = 'PS_PSP_PNR'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-ref_tabname    = 'MSEG'.
      ls_fieldcat-no_out         = ' '.
      ls_fieldcat-col_pos        = '13'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_fieldcat.
      ls_fieldcat-fieldname      = 'COUNT'.
      ls_fieldcat-tabname        = 'LT_FINAL'.
      ls_fieldcat-do_sum = 'X'.
      append ls_fieldcat to lt_fieldcat.
      clear ls_sort.
      ls_sort-fieldname         = 'LGORT'.
      ls_sort-tabname           = 'LT_FINAL'.
      ls_sort-subtot            = 'X'.
      append ls_sort to gt_sort.
    endform.                    "E01_FIELDCAT_INIT
    *&      Form  e04_comment_build
    form e04_comment_build using e04_lt_top_of_page type slis_t_listheader.
      data : v_time(10) type c,                                 "#EC *
             ls_line type slis_listheader,
             v_text(50) type c,
             v_date_low(10)  type c,
             v_date_high(10)  type c.
      write s_budat-low to v_date_low.
      write s_budat-high to v_date_high.
      if v_date_low = '00.00.0000'.
        v_date_low = '01.01.0000'.
      endif.
      if v_date_high = '00.00.0000'.
        v_date_high = '31.12.9999'.
      endif.
      if s_eqtyp = 'IEQC' or s_eqtyp = 'IEQD'.
        concatenate 'RCV Stocks between' v_date_low 'and' v_date_high
        into v_text separated by space.
      elseif s_eqtyp = 'IEQE' or s_eqtyp = 'IEQF'.
        concatenate 'ESN Stocks between' v_date_low 'and' v_date_high
        into v_text separated by space.
      else.
        concatenate 'Stocks between' v_date_low 'and' v_date_high
         into v_text separated by space.
      endif.
      clear ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = v_text.
      append ls_line to e04_lt_top_of_page.
    endform.                    " e04_comment_build
          FORM TOP_OF_PAGE                                              *
    form top_of_page.                                           "#EC CALLED
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = gt_list_top_of_page.
    endform   .                    "TOP_OF_PAGE
    *&      Form  display_report
    form display_report using lt_final    type tt_final
                              lt_fieldcat type slis_t_fieldcat_alv.
      data: lw_fieldcatalog  type slis_fieldcat_alv,
            lf_tabix type sy-tabix.
      loop at lt_fieldcat into lw_fieldcatalog.
        lf_tabix = sy-tabix.
        if lw_fieldcatalog-fieldname = 'LGORT'.
          lw_fieldcatalog-do_sum     = 'X'.
    X_fieldcatalog-CHECKBOX   = 'X'.
    X_FIELDCATALOG-INPUT      = 'X'.
        endif.
        modify lt_fieldcat  from lw_fieldcatalog index lf_tabix.
      endloop.
    POPULATE LAYOUT STRUCTURE
      gs_layout-subtotals_text = 'TOTAL'.
      gs_layout-totals_text    = 'GRAND TOTAL'.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_background_id         = 'ALV_BACKGROUND'
          i_callback_program      = gf_repid
         i_callback_pf_status_set = 'PF_STATUS'
          i_callback_user_command = 'USER_COMMAND'
          i_structure_name        = 'ITAB_FINAL'
          is_layout               = gs_layout
          it_fieldcat             = lt_fieldcat[]
          it_special_groups       = gt_sp_group[]
          it_sort                 = gt_sort[]
          it_filter               = gt_filter[]
          i_save                  = gf_save
          is_variant              = gf_variant
          it_events               = gt_events[]
          is_print                = gs_print
          it_alv_graphics         = gt_alv_graphics[]
          it_excluding            = gt_excluding
        tables
          t_outtab                = lt_final.
    endform.                    " display_report
    *&      Form  USER_COMMAND
    form user_command using g_ucomm type sy-ucomm
                            g_field type slis_selfield.         "#EC *
      case g_ucomm.
        when '&IC1'.
          message e009(zmmabap).
      endcase.
    endform.                    "USER_COMMAND
    *&      Form  eventtab_build
    form eventtab_build changing lt_events type slis_t_event.
      constants:
      gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type = 0
        importing
          et_events   = lt_events.
      read table lt_events with key name = slis_ev_top_of_page
      into ls_event.
      if sy-subrc = 0.
        move gc_formname_top_of_page to ls_event-form.
        append ls_event to lt_events.
      endif.
    endform.                    "eventtab_build
    *&      Form  ftp_data
          text
    form ftp_data using lt_ftp type tt_ftp.
      data: e_file type rlgrap-filename,                        "#EC *
          duser(64) TYPE c VALUE 'biftp',
          dpwd(64) TYPE c VALUE 'biftp',
          dhost(64) TYPE c VALUE '172.17.7.70',
            dfile(256) type c, " VALUE 'FWP_Stocks.txt',
            dest type rfcdes-rfcdest value 'SAPFTP'.
      concatenate 'FWP_Data_' s_budat-low '_' s_budat-high '.txt' into dfile.
      data:   dhdl type i,
              blob_length type i,
              mi_key type i value 26101957,
              mi_pwd_len type i,
              mi_handle type i,                                 "#EC *
              lf_fnam_sour type gf_fnam_sour,
              lf_p_mail type gf_p_mail,
              lf_msg type gf_msg,
              lf_command type gf_command.
    *download the file..
    IF IT_FTP[] IS NOT INITIAL.
      call 'AB_RFC_X_SCRAMBLE_STRING'
             id 'SOURCE' field dpwd id 'KEY' field mi_key
             id 'SCR' field 'X' id 'DESTINATION' field dpwd
             id 'DSTLEN' field mi_pwd_len.
      call function 'FTP_CONNECT'
        exporting
          user            = duser
          password        = dpwd
          host            = dhost
          rfc_destination = dest
        importing
          handle          = dhdl.
      blob_length = x * 208.
      call function 'FTP_R3_TO_SERVER'
        exporting
          handle         = dhdl
          fname          = dfile
          blob_length    = blob_length
          character_mode = ' '
        tables
          blob           = lt_ftp
        exceptions
          tcpip_error    = 1
          command_error  = 2
          data_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.
      else.
        lf_fnam_sour = x.
        lf_p_mail = '[email protected]'.
        concatenate text-013 lf_fnam_sour lf_msg into lf_msg separated by space.
        concatenate 'echo "' lf_msg '" | mailx -s "SAP feed file is placed on ftp"'
        into lf_command.
        concatenate lf_command lf_p_mail into lf_command separated by space.
        condense lf_command.
        perform uxcmd using lf_command.
        write : 'FTP DONE ) !!! '.
       ENDIF.
    Disconnect
        call function 'FTP_DISCONNECT'
          exporting
            handle = dhdl.
      endif.
      clear : lf_fnam_sour ,
              lf_p_mail ,
              lf_msg ,
              lf_command .
    endform.                    " ftp_data
    *&      Form  uxcmd
    form uxcmd  using  p_command.                               "#EC *
      "issue UNIX wa_command by calling system function.
      data: begin of itab occurs 0,                             "#EC *
             line(255),
            end of itab.
      call 'SYSTEM' id 'COMMAND' field  p_command
                    id 'TAB'     field  itab-sys.
    endform.                    " uxcmd
    *&      Form  fr_display_no_data
    form fr_display_no_data .
      skip 1.
      write: /2  'No relevant data Exists for the following Selection.'.
    endform.                    " fr_display_no_data
    <b>
    include zmmr_stockdetails_variables .
    ***************************************</b>
    TYPE POOLS
    type-pools: slis.
    STRUCTURES
    types:  begin of tw_doc,      "MSEG
             mblnr type mblnr,
             mjahr type mjahr,
             zeile type mblpo,
             bwart type bwart,
             matnr type matnr,
             werks type werks_d,
             lgort type lgort_d,
             shkzg type shkzg,
             bwtar type bwtar_d,
             ebeln type bstnr,
             ps_psp_pnr type ps_psp_pnr,
             budat type budat,
             equnr type equnr,
             sernr type gernr,
             obknr type objknr,
             datum type datum,
             uzeit type uzeit,
             name1 type name1,
             maktx type maktx,
             agency type sgtxt,
            end of tw_doc,
            tt_doc type standard table of tw_doc,
            begin of tw_doc_temp,      "MSEG
             mblnr type mblnr,
             mjahr type mjahr,
             sernr type gernr,
             bwart type bwart,
             datum type datum,
             uzeit type uzeit,
             werk  type werks_d,
             plant type lgort_d,
            end of tw_doc_temp,
            tt_doc_temp type standard table of tw_doc_temp,
            begin of tw_ser03,                                  "SER03
              obknr type objknr,
              mblnr type mblnr,
              mjahr type mjahr,
              zeile type mblpo,
              bwart type bwart,
              datum type datum,
              uzeit type uzeit,
              anzsn type anzsn,
              werk  type werks_d,
              lagerort type lgort_d,
            end of tw_ser03,
            tt_ser03 type standard table of tw_ser03,
            begin of tw_objk ,        "OBJK
              obknr type objknr,
              equnr type equnr,
              sernr type gernr,
              matnr type matnr,
            end of tw_objk,
            tt_objk type standard table of tw_objk,
            begin of tw_equi,          "EQUI
              equnr type equnr,
            end of tw_equi,
            tt_equi type standard table of tw_equi,
            begin of tw_final ,
              equnr type equnr, "-------change
              matnr type matnr,
              mjahr type mjahr,
              maktx type maktx,
              sernr type gernr,
              budat type budat,
              uzeit type uzeit,
              ebeln type bstnr,
              werks type werks_d,
              name1 type name1,
              lgort type lgort_d,
              shkzg type shkzg,
              agency type sgtxt,
              mblnr type mblnr,
              zeile type mblpo,
              obknr type objknr,
              bwart type bwart,
              bwtar type bwtar_d,
              ps_psp_pnr type ps_psp_pnr,
              count type i,
            end of tw_final,
            tt_final type standard table of tw_final,

  • Problem in executing BAPI_GOODSMVT_CREATE

    Hello Experts,
    I have created STO. From STO  I have created an Inbound Delivery.Now I have to do PGR by using BAPI_GOODSMVT_CREATE.
    I am passing
      GOODSMVT_CODE  01
    GOODSMVT_ITEM
      Material
      Plant
      Storage Location
      Batch
      Move _Type - 109  (As mentioned by Functional)
      Entry_QNT
      Entry_UOM
      PO_Number
      PO_Item
      No_More_GR
      MVT_IND - B
      DELIV_NUMB_TO_SEARCH
      DELIV_ITEM_TO_SEARCH
    But error message getting populated in IT_RETURN
    E M7                   036 No goods receipt possible for purchase order 5700000855 00010
    Can anyone solve this problem??
    One more query is this the correct BAPI to do PGR via tcode VL32N??

    Hi please check this sample code. it creates goods movement using this BAPIits just that its a upload program. you can modify by your requirement.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
    col1(30)    TYPE c,
    col2(30)    TYPE c,
    col3(30)    TYPE c,
    col4(30)    TYPE c,
    col5(30)    TYPE c,
    col6(30)    TYPE c,
    col7(30)    TYPE c,
    col8(30)    TYPE c,
    col9(30)    TYPE c,
    col10(30)    TYPE c,
    col11(30)    TYPE c,
    END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
    wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    * At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    field_name = 'P_FILE'
    IMPORTING
    file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    *     I_FIELD_SEPERATOR        =
    i_line_header            =  'X'
    i_tab_raw_data           =  it_raw       " WORK TABLE
    i_filename               =  p_file
    TABLES
    i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
    EXCEPTIONS
    conversion_failed        = 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.
    *** Create batch upload using BAPI_GOODSMVT_CREATE
    PERFORM CREATE_BATCH_UPLOAD.
    *&      Form  CREATE_BATCH_UPLOAD
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM CREATE_BATCH_UPLOAD .
    DATA : GT_GOODSMVT_HEADER  LIKE BAPI2017_GM_HEAD_01.
    DATA : GOODSMVT_ITEM  TYPE TABLE OF BAPI2017_GM_ITEM_CREATE,
    WA_GOODSMVT_ITEM TYPE BAPI2017_GM_ITEM_CREATE,
    *       L_RETURN LIKE BAPIRET2,
    RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
    TYPES : BEGIN OF ITAB,
    MATNR TYPE MATNR,
    WERKS TYPE WERKS_D,
    CHARG TYPE CHARG_D,
    END OF ITAB.
    DATA : IT_ITAB TYPE STANDARD TABLE OF ITAB,
    WA_ITAB TYPE ITAB.
    DATA : MATERIALDOCUMENT TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.
    *       MATDOCUMENTYEAR TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR.
    *DATA : GT_GOODSMVT_HEARRET LIKE BAPI2017_GM_HEAD_RET.
    DATA : V_LINES TYPE CHAR4,
    GOODSMVT_CODE TYPE BAPI2017_GM_CODE VALUE '04'.
    GT_GOODSMVT_HEADER-PSTNG_DATE = SY-DATUM.
    GT_GOODSMVT_HEADER-DOC_DATE   = SY-DATUM.
    LOOP AT IT_DATATAB INTO WA_DATATAB.
    WA_GOODSMVT_ITEM-MATERIAL = wa_datatab-col7.
    WA_GOODSMVT_ITEM-MOVE_BATCH = wa_datatab-col10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    INPUT         = WA_GOODSMVT_ITEM-MOVE_BATCH
    IMPORTING
    OUTPUT        = WA_GOODSMVT_ITEM-MOVE_BATCH
    WA_GOODSMVT_ITEM-PLANT = wa_datatab-col4.
    WA_GOODSMVT_ITEM-STGE_LOC = wa_datatab-col5.
    WA_GOODSMVT_ITEM-BATCH = wa_datatab-col9.
    WA_GOODSMVT_ITEM-MOVE_TYPE = wa_datatab-col3.
    WA_GOODSMVT_ITEM-ENTRY_QNT = wa_datatab-col8.
    WA_GOODSMVT_ITEM-MOVE_STLOC = wa_datatab-col6.
    WA_GOODSMVT_ITEM-ITEM_TEXT = wa_datatab-col11.
    APPEND WA_GOODSMVT_ITEM TO GOODSMVT_ITEM.
    CLEAR WA_GOODSMVT_ITEM.
    ENDLOOP.
    select MATNR WERKS CHARG from MCHB into table it_itab for all entries in GOODSMVT_ITEM
    where matnr = GOODSMVT_ITEM-MATERIAL and
    charg = GOODSMVT_ITEM-MOVE_BATCH.          " GOODSMVT_ITEM-MOVE_BATCH.
    DESCRIBE TABLE GOODSMVT_ITEM LINES V_LINES.
    IF IT_ITAB[] IS  INITIAL.
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
    GOODSMVT_HEADER               = GT_GOODSMVT_HEADER
    GOODSMVT_CODE                 = GOODSMVT_CODE
    *   TESTRUN                       = ' '
    *   GOODSMVT_REF_EWM              =
    IMPORTING
    *    GOODSMVT_HEADRET              = GT_GOODSMVT_HEARRET
    MATERIALDOCUMENT              = MATERIALDOCUMENT
    *    MATDOCUMENTYEAR               = MATDOCUMENTYEAR
    TABLES
    GOODSMVT_ITEM                 = GOODSMVT_ITEM
    *   GOODSMVT_SERIALNUMBER         =
    RETURN                        = RETURN
    *   GOODSMVT_SERV_PART_DATA       =
    *   EXTENSIONIN                   =
    IF RETURN[] IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT          = 'X'
    *  IMPORTING
    *    RETURN        = l_return
    WRITE : TEXT-001 , MATERIALDOCUMENT.
    WRITE : TEXT-005 , V_LINES.
    ELSE.
    WRITE: TEXT-002 ,
    / RETURN-MESSAGE.
    ENDIF.
    ELSE.
    WRITE : TEXT-003.
    ULINE.
    Loop at it_itab into wa_itab.
    WRITE : TEXT-004 , wa_itab-matnr , wa_itab-charg.
    ENDLOOP.
    ENDIF.
    ENDFORM.                    " CREATE_BATCH_UPLOAD

  • Problem Currency field value

    Hi,
    I am trying to call a subroutine in ABAP program from SAPscript. i.e. passing PO number and getting price details for the line items.My problem is I am not able to assign a currency value to a character value in program, so that I am not able to get the currency value in script.
    Here is my example code:
    /:   PERFORM GET_PRICE_DETAIL IN PROGRAM ZCAEUR_SAPSCRIPT_EXTERNAL_READ
    /:   USING &EKPO-EBELN&
    /:   USING &EKPO-EBELP&
    /:   CHANGING &Z_PRICE&
    /:   CHANGING &Z_CURR&
    /:   CHANGING &Z_PER&
    /:   CHANGING &Z_UOM&
    /:   ENDPERFORM
    In program:
    FORM get_price_detail tables p_in_tab  like int_tab[]
                                   p_out_tab like out_tab[].
    read table p_in_tab with key name = 'EKPO-EBELN'.
      if sy-subrc = 0.
        call function 'CONVERSION_EXIT_ALPHA_INPUT'
             exporting
                  input  = w_ebeln
             importing
                  output = w_ebeln.
      endif.
    *get delivery notes
      select bprme netpr peinh prsdr
             into corresponding fields of table tb_docs
             from ekpo
            where ebeln = w_ebeln
            and ebelp = '00010'.
      check sy-subrc = 0.
       clear: p_out_tab.
        loop at tb_docs into wa_docs.
          p_out_tab-name = 'Z_PRICE'.
          p_out_tab-value = wa_docs-netpr.
          append  p_out_tab.
          p_out_tab-name = 'Z_CURR'.
          p_out_tab-value = wa_docs-waers.
          append p_out_tab.
          p_out_tab-name = 'Z_PER'.
          p_out_tab-value = wa_docs-peinh.
          append p_out_tab.
          p_out_tab-name = 'Z_UOM'.
          p_out_tab-value = wa_docs-bprme.
          append p_out_tab.
            endloop.
    Endform.
    Could you please help me to pass a currency(amount) value to SAPscript.
    Thanks and Regards,
    Sankar

    Hi
    see the sample code and do accordingly
    REPORT ZMPO1 .
    form get_freight tables in_par structure itcsy out_par structure itcsy.
    tables: ekko,konv,t685t.
    data: begin of itab occurs 0,
             ebeln like ekko-ebeln,
             knumv like ekko-knumv,
           end of itab.
    data: begin of itab1 occurs 0,
             knumv like konv-knumv,
             kposn like konv-kposn,
             kschl like konv-kschl,
             kbetr like konv-kbetr,
             waers like konv-waers,
             kwert like konv-kwert,
           end of itab1.
    data: begin of iout occurs 0,
             kschl like konv-kschl,
             vtext like t685t-vtext,
             kbetr like konv-kbetr,
             kwert like konv-kwert,
           end of iout.
    data v_po like ekko-ebeln.
    read table in_par with key 'EKKO-EBELN'.
    if sy-subrc = 0.
       v_po = in_par-value.
       select
         ebeln
         knumv
      from ekko
      into table itab
      where ebeln = v_po.
      if sy-subrc = 0.
        loop at itab.
          select
            knumv
            kposn
            kschl
            kbetr
            waers
            kwert
          into table itab1
          from konv
          where knumv = itab-knumv and
                kappl = 'M'.
        endloop.
        loop at itab1.
          if itab1-kposn <> 0.
            select single * from t685t
                              where kschl = itab1-kschl
                                and kappl = 'M'
                                and spras = 'EN'.
            iout-vtext = t685t-vtext.
            iout-kschl = itab1-kschl.
            iout-kbetr = itab1-kbetr.
            iout-kwert = itab1-kwert.
            append iout.
            clear iout.
          endif.
        endloop.
        sort itab1 by kposn.
        loop at iout.
          sort iout by kschl.
          if ( iout-kschl eq 'GSDC' OR
               iout-kschl eq 'GSFR' OR
               iout-kschl eq 'GSIR' ).
            at end of kschl.
              read table iout index sy-tabix.
              sum.
             write:/ iout-kschl,iout-vtext,iout-kwert.
          out_par-name = 'A1'.
          out_par-value = iout-vtext.
          append out_par.
          out_par-name = 'A2'.
          out_par-value = iout-kwert.
          append out_par.
              endat.
            endif.
          endloop.
        endif.
      endif.
    endform.
    IN THE FORM I AM WRITING THIS CODE.
    /:DEFINE &A1& = ' '
    /:DEFINE &A2& = ' '
    /:PERFORM GET_FREIGHT IN PROGRAM ZMFORM_PO1
    /:USING &EKKO-EBELN&
    /:CHANGING &A1&
    /:CHANGING &A2&
    /:ENDPERFORM
    &A1&
    &A2&
    This Code is to be written in the PO form under ADDRESS window.
    /:DEFINE &A1& = ' '
    /:DEFINE &A2& = ' '
    /:DEFINE &A3& = ' '
    /:DEFINE &A4& = ' '
    /:DEFINE &A5& = ' '
    /:DEFINE &A6& = ' '
    /:PERFORM GET_VENDOR IN PROGRAM ZMFORM_PO
    /:USING &EKKO-EBELN&
    /:CHANGING &A1&
    /:CHANGING &A2&
    /:CHANGING &A3&
    /:CHANGING &A4&
    /:CHANGING &A5&
    /:CHANGING &A6&
    /:ENDPERFORM
    &A1&
    &A2&
    &A3&
    &A4&
    &A5&
    &A6&
    Regards
    Anji

  • Problems with BAPI_ENTRYSHEET_CREATE

    Hi,
    I am using that function to fill several lines in a document.
    He puts the lines but the field costcenter - kostl is the same to every line but i am sending diferent kostl's in the function.
    It apears that he choses random number in the table sendt in the function and puts to every line.
    What could be the problem??
    i am using the code:
            LOOP AT it_am INTO wa_am WHERE xblnr = wa_am_i-xblnr
                                                   AND txz01 = wa_am_i-txz01.
              counter = counter + 1.
              it_eskn-pckg_no = pac.
              it_eskn-gl_account = it_account-g_l_acct.
              it_eskn-costcenter = wa_am-kostl.
              it_eskn-serial_no = counter.
              it_eskn-counter = counter.
              APPEND it_eskn.
              CLEAR v_quant.
              it_eskl-percentage = ( wa_am-tbtwr / v_quant ) * 100."wa_am_h-mkntm.
              it_eskl-pckg_no = pac.
              it_eskl-line_no = counter.
              APPEND  it_eskl.
            ENDLOOP.
          CALL FUNCTION 'BAPI_ENTRYSHEET_CREATE'
            EXPORTING
              entrysheetheader            = wa_header
              testrun                     = mode
            IMPORTING
              entrysheet                  = num
            TABLES
              entrysheetaccountassignment = it_eskn
              entrysheetservices          = it_esll
              entrysheetsrvaccassvalues   = it_eskl
              return                      = it_return.
    in table it_eskn there are 100 lines with diferent kostl.
    tks in advanced

    ohhh....
    do i need to run the function  CONVERSION_EXIT_ALPHA_INPUT ??
    stupid error
    i will try...tks

Maybe you are looking for

  • How to bypass the parameter prompting screen?

    Hello, We are passing parameters from java code using the ParameterFieldController.setCurrentValue method. However, even though all parameters required by a given report are informed, when we try to generate a report, a prompt screen is systematicall

  • XSL benefits

    Hello all, Can anyone tell me what experiences for having Servlets+XML+XSL versus JSP+Servlets? If I separate the view to the JSP and use Servlets for controlling the application, what benefits will I gain if I use XSL+XML to describe the view instea

  • Runtime Error on startup NSU

    Installed the NSU (nokia Software Updater) via the website. I'm running XP pro & office Pro P4 2ghz THE ERROR on startup of NSU Runtime error! Program:...Nokia software updater\nsu_ui_client.exe abnormal program termination. What the... is this!!???

  • Setting javascript to make falling snow

    I have managed to make a flake in Edge to flash randomly after following a tutorial on lynda.com My javascript knowledge is fairly limited but I used the following code on a trigger inside the flake symbol I made: var randomFrame = Math.floor(Math.ra

  • Cisco 1142 WGB in a controller based network

    Hi, I have trouble with Cisco AP1142 which is configured in WGB mode. I'm trying to get it work in a controller based network, where LAPs are configured in H-REAP. SSID where WGB should be associated drops it traffic to VLAN60. Security type is WPA2-