Skip to Content
avatar image
-1
Former Member

Creating Po with bapi, via ean11

Hello everyone.

I am creating po(me21n) with text file (format is 123123 1 matnr and quantity)

when i upload this texts. it works good. But i need to make text file format

ean11 and quantity. (8681231231231 1 for example) i could not find any solutions.

You can see my code below.

Thanks

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

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

*& Report ZIADE

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

*&

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

REPORT ZIADE2.





CONSTANTS : C_X VALUE 'X'.

DATA: X TYPE I.

DATA : V_FILE TYPE STRING.

DATA : BEGIN OF IT_DATA OCCURS 0,

         "CREAT_DATE(50), " Yaratma Tarihi

         " VENDOR(50), "satıcı

         EMATN(18), "Malzeme numarası

         " SHORT_TEXT(50)  ,

         "GRUP_ART(50),

         "PLANT(50),

         QUANTITY(13),

         "PO_UNIT(50),

         "RET_ITEM(1),

         "DOCTYPE(50),



       END OF IT_DATA.

DATA : HEADER  LIKE BAPIMEPOHEADER,

       HEADERX LIKE BAPIMEPOHEADERX.

DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

DATA : ACCOUNT  LIKE BAPIMEPOACCOUNT OCCURS 0 WITH HEADER LINE,

       ACCOUNTX LIKE BAPIMEPOACCOUNTX OCCURS 0 WITH HEADER LINE.

DATA : ITEMSCHEDULE  LIKE BAPIMEPOSCHEDULE OCCURS 0 WITH HEADER LINE,

       ITEMSCHEDULEX LIKE BAPIMEPOSCHEDULX OCCURS 0 WITH HEADER LINE.

DATA : ITEM   LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,

       ITEMX  LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,



       RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.



"DATA : W_HEADER(40)  VALUE 'PO Header',

"      PURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER,

"     DELIVERY_DATE LIKE BAPIMEPOSCHEDULE-DELIVERY_DATE.







SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.



PARAMETERS: P_FILE TYPE RLGRAP-FILENAME DEFAULT 'C:\Users\ERKANKA\Desktop\me21n.txt',

            VENDOR LIKE HEADER-VENDOR DEFAULT '1001',

            WERKS  LIKE ITEM-PLANT DEFAULT '3125'.

"MATL   LIKE ITEM-MATL_GROUP.

SELECTION-SCREEN END OF BLOCK B1.







AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.



  CALL FUNCTION 'F4_FILENAME'

    EXPORTING

      PROGRAM_NAME  = SYST-CPROG

      DYNPRO_NUMBER = SYST-DYNNR

      FIELD_NAME    = ' '

    IMPORTING

      FILE_NAME     = P_FILE.



START-OF-SELECTION.



  V_FILE = P_FILE.



  CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

      FILENAME                = V_FILE

      FILETYPE                = 'ASC'

      HAS_FIELD_SEPARATOR     = ' '

    TABLES

      DATA_TAB                = IT_DATA

    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.





END-OF-SELECTION.



  PERFORM UPLOAD.



FORM UPLOAD.

  LOOP AT IT_DATA.

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

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        INPUT  = IT_DATA-EMATN

      IMPORTING

        OUTPUT = IT_DATA-EMATN.

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



    HEADER-DOC_TYPE = 'ZKID' .

    HEADER-VENDOR = VENDOR.

    HEADER-CREAT_DATE = SY-DATUM .

    HEADER-CREATED_BY = SY-UNAME .

    HEADER-PURCH_ORG = '1000' .

    HEADER-PUR_GROUP = 'S99' .

    HEADER-COMP_CODE = '3000' .







    HEADERX-COMP_CODE = C_X.

    HEADERX-DOC_TYPE = C_X.

    HEADERX-VENDOR = C_X.

    HEADERX-CREAT_DATE = C_X.

    HEADERX-CREATED_BY = C_X.

    HEADERX-PURCH_ORG = C_X.

    HEADERX-PUR_GROUP = C_X.





    ITEM-STGE_LOC = '1001'.

    ITEM-RET_ITEM = 'X'.

    ITEM-PO_ITEM = '10'.

    ITEM-QUANTITY = IT_DATA-QUANTITY.

    ITEM-EMATERIAL =  IT_DATA-EMATN.

    ITEM-SHORT_TEXT = 'bapi deneme'.

    ITEM-ITEM_CAT = 'N' .

    ITEM-MATL_GROUP = '313'.

    ITEM-PLANT = WERKS .

    "ITEM-PO_UNIT = 'M'.







    APPEND ITEM. CLEAR ITEM.





*

    ITEMX-RET_ITEM = C_X.

    ITEMX-PO_ITEM = '10'.

    ITEMX-STGE_LOC = C_X.

    ITEMX-EMATERIAL = C_X.

    "ITEMX-SHORT_TEXT = C_X.

    ITEMX-QUANTITY = C_X.

    ITEMX-ITEM_CAT = C_X.

    "ITEMX-MATL_GROUP = C_X.

    ITEMX-PLANT = C_X.

    "ITEMX-PO_UNIT = C_X.

    ITEM-RET_ITEM = C_X.





    APPEND ITEMX. CLEAR ITEMX.







    ITEMSCHEDULE-PO_ITEM = '00010'.



    APPEND ITEMSCHEDULE.

    CLEAR ITEMSCHEDULE.







    ITEMSCHEDULEX-PO_ITEM = C_X.



    APPEND ITEMSCHEDULEX.

    CLEAR ITEMSCHEDULEX.







    CALL FUNCTION 'BAPI_PO_CREATE1'

      EXPORTING

        POHEADER  = HEADER

        POHEADERX = HEADERX

        " IMPORTING

        "EXPPURCHASEORDER = PURCHASEORDER

      TABLES

        RETURN    = RETURN

        POITEM    = ITEM

        POITEMX   = ITEMX.





*



    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        WAIT   = ABAP_TRUE

      IMPORTING

        RETURN = RETURN.



    " LOOP AT RETURN.









    "CALL FUNCTION 'POPUP_TO_INFORM'

    " EXPORTING

    "  TITEL = 'Sipariş Durumu'

    " TXT1  = RETURN-MESSAGE

    " TXT2  = ' '

    " TXT3  = '  '

*         TXT4  = ' '

    " WRITE / RETURN-MESSAGE.





    DATA: INDEX TYPE I.

    DO 2 TIMES.

      INDEX = SY-INDEX * 50.



      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

        EXPORTING

          PERCENTAGE = INDEX

          TEXT       = 'Konsinye İade Siparişleri Oluşturuluyor.'.

      WAIT UP TO 1 SECONDS.

    ENDDO.



    CALL FUNCTION 'MESSAGES_INITIALIZE'.



    LOOP AT RETURN.

      CALL FUNCTION 'MESSAGE_STORE'

        EXPORTING

          ARBGB                   = RETURN-ID

          EXCEPTION_IF_NOT_ACTIVE = ' '

          MSGTY                   = RETURN-TYPE

          MSGV1                   = RETURN-MESSAGE_V1

          MSGV2                   = RETURN-MESSAGE_V2

          MSGV3                   = RETURN-MESSAGE_V3

          MSGV4                   = RETURN-MESSAGE_V4

          TXTNR                   = RETURN-NUMBER

          ZEILE                   = ' '

        EXCEPTIONS

          MESSAGE_TYPE_NOT_VALID  = 1

          NOT_ACTIVE              = 2

          OTHERS                  = 3.

    ENDLOOP.



    CALL FUNCTION 'MESSAGES_STOP'

      EXCEPTIONS

        A_MESSAGE = 04

        E_MESSAGE = 03

        I_MESSAGE = 02

        W_MESSAGE = 01.



    IF NOT SY-SUBRC IS INITIAL.



      CALL FUNCTION 'MESSAGES_SHOW'

        EXPORTING

          I_USE_GRID         = 'X'

          "i_amodal_window    = 'X'

        EXCEPTIONS

          INCONSISTENT_RANGE = 1

          NO_MESSAGES        = 2

          OTHERS             = 3.

    ENDIF.





  ENDLOOP.









ENDFORM.
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 14, 2017 at 06:41 AM

    Hi Erkan,

    first of all, please, format the code because it's pretty hard to read it.
    Second, which error you get in return table?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 14, 2017 at 12:22 PM

    Hello.

    I updated.. I dont get error with this style.

    But i want to make my import txt file format ean11 Quantity style

    Add comment
    10|10000 characters needed characters exceeded