How can we add attachment in the PO using BAPI

How can we add attachment in the PO? I am using the BAPI_PO_CREATE1 function module to create the PO. I am getting a file from legacy system, this I need to add as an attachment into the particular PO through programming.
Note: After creation of PO the attachment should be available in ME23n transaction.

REPORT  ZBAPI_PO_CRATE.
data : PO_HEADER like BAPIEKKOC.
data : PO_HEADER_ADD_DATA like BAPIEKKOA.
data : PO_ITEMS like BAPIEKPOC occurs 0 with header
line.
data : PO_ITEM_SCHEDULES like BAPIEKET occurs 0 with
header line.
data : RETURN like BAPIRETURN occurs 0 with header
line.
DATA : BEGIN OF TAB OCCURS 0,
       PO_NUMBER like BAPIEKKOC-PO_NUMBER,
       DOC_DATE(10),
       DOC_TYPE like BAPIEKKOC-DOC_TYPE,
       CO_CODE like BAPIEKKOC-CO_CODE,
       PURCH_ORG like BAPIEKKOC-PURCH_ORG,
       PUR_GROUP like BAPIEKKOC-PUR_GROUP,
       VENDOR like BAPIEKKOC-VENDOR,
       PMNTTRMS like BAPIEKKOA-PMNTTRMS,
       INCOTERMS1 like BAPIEKKOA-INCOTERMS1,
       INCOTERMS2 like BAPIEKKOA-INCOTERMS2,
       PO_ITEM like  BAPIEKPOC-PO_ITEM,
       MATERIAL like BAPIEKPOC-MATERIAL,
       PUR_MAT like BAPIEKPOC-PUR_MAT,
       ITEM_CAT like BAPIEKPOC-ITEM_CAT,
       PLANT like BAPIEKPOC-PLANT,
       NET_PRICE like BAPIEKPOC-NET_PRICE,
       TAX_CODE like BAPIEKPOC-TAX_CODE,
       DELIV_DATE(10),
       QUANTITY like BAPIEKET-QUANTITY,
     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 ERROR
LOG
data : begin of it_success occurs 0,
        PURCHASEORDER LIKE ekko-ebeln,  "PROJECT
      end of it_success.
data : begin of it_error occurs 0,
        pono like  ekko-ebeln,
        err_msg(73) TYPE c,    "TO RETREIVE ERROR
MESSAGES
     end of it_error.
data : pono like  ekko-ebeln.
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.
    case itab1-col.
      when '0001'. "PGNAM
        TAB-PO_NUMBER = itab1-value.
      when '0002'. "RONAM
        TAB-DOC_DATE = itab1-value.
      when '0003'. "JVLEVEL
        TAB-DOC_TYPE = itab1-value.
      when '0004'. "FTTYPE
        TAB-CO_CODE = itab1-value.
      when '0005'. "LANG
        TAB-PURCH_ORG =  itab1-value.
      when '0006'. "LTEXT
        TAB-PUR_GROUP = itab1-value.
      when '0007'. "LTEXT
        TAB-VENDOR = itab1-value.
      when '0008'. "LTEXT
        TAB-PMNTTRMS = itab1-value.
      when '0009'. "LTEXT
        TAB-INCOTERMS1 = itab1-value.
      when '0010'. "FTTYPE
        TAB-INCOTERMS2 = itab1-value.
      when '0011'. "FTTYPE
        TAB-PO_ITEM = itab1-value.
      when '0012'. "FTTYPE
        TAB-MATERIAL = itab1-value.
      when '0013'. "FTTYPE
        TAB-PUR_MAT = itab1-value.
      when '0014'. "FTTYPE
        TAB-ITEM_CAT = itab1-value.
      when '0015'. "FTTYPE
        shift itab1-value left deleting leading space.
        TAB-PLANT = itab1-value.
      when '0016'. "FTTYPE
        TAB-NET_PRICE = itab1-value.
      when '0017'. "FTTYPE
        TAB-TAX_CODE = itab1-value.
      when '0018'. "FTTYPE
        TAB-DELIV_DATE = itab1-value.
      when '0019'. "FTTYPE
        TAB-QUANTITY = itab1-value.
    endcase.
  endloop.
  append tab.
  clear tab.
  sort tab by PO_NUMBER.
  DELETE TAB WHERE PO_NUMBER = SPACE.
  loop at tab.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = tab-material
      IMPORTING
        OUTPUT = tab-material.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = tab-PUR_MAT
      IMPORTING
        OUTPUT = tab-PUR_MAT.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = tab-vendor
      IMPORTING
        OUTPUT = tab-vendor.
    concatenate tab-doc_DATE+4(4) tab-doc_DATE+2(2)
tab-doc_DATE+0(2)
into tab-doc_DATE.
    concatenate tab-DELIV_DATE+4(4)
tab-DELIV_DATE+2(2)
tab-DELIV_DATE+0(2) into tab-DELIV_DATE.
    pono = tab-PO_NUMBER.
    if tab-po_number = pono.
      PO_HEADER-DOC_DATE = tab-DOC_DATE.
      PO_HEADER-DOC_TYPE = tab-DOC_TYPE.
      PO_HEADER-CO_CODE  = tab-CO_CODE.
      PO_HEADER-PURCH_ORG = tab-PURCH_ORG.
      PO_HEADER-PUR_GROUP = tab-PUR_GROUP.
      PO_HEADER-VENDOR = tab-VENDOR.
      PO_HEADER-PO_NUMBER = tab-PO_NUMBER.
      PO_HEADER_ADD_DATA-PMNTTRMS = tab-PMNTTRMS.
      PO_HEADER_ADD_DATA-INCOTERMS1 = tab-INCOTERMS1.
      PO_HEADER_ADD_DATA-INCOTERMS2 = tab-INCOTERMS2.
      PO_ITEMS-PO_ITEM = tab-PO_ITEM.
      PO_ITEMS-MATERIAL = tab-MATERIAL.
      PO_ITEMS-PUR_MAT = tab-PUR_MAT.
      PO_ITEMS-ITEM_CAT = tab-ITEM_CAT.
      PO_ITEMS-PLANT = tab-PLANT.
      PO_ITEMS-NET_PRICE = tab-NET_PRICE.
      PO_ITEMS-TAX_CODE = tab-TAX_CODE.
      append po_items.
      PO_ITEM_SCHEDULES-PO_ITEM = tab-PO_ITEM.
      PO_ITEM_SCHEDULES-DELIV_DATE = tab-DELIV_DATE.
      PO_ITEM_SCHEDULES-QUANTITY =  tab-QUANTITY.
      append PO_ITEM_SCHEDULES.
    endif.
    at end of PO_NUMBER.
      CALL FUNCTION 'BAPI_PO_CREATE'
        EXPORTING
          PO_HEADER                        = PO_HEADER
         PO_HEADER_ADD_DATA               =
PO_HEADER_ADD_DATA
*           HEADER_ADD_DATA_RELEVANT         =
*           PO_ADDRESS                       =
*           SKIP_ITEMS_WITH_ERROR            = 'X'
*           ITEM_ADD_DATA_RELEVANT           =
*           HEADER_TECH_FIELDS               =
       IMPORTING
         PURCHASEORDER                    =
PURCHASEORDER
        TABLES
          PO_ITEMS                         = PO_ITEMS
*           PO_ITEM_ADD_DATA                 =
          PO_ITEM_SCHEDULES                =
PO_ITEM_SCHEDULES
*           PO_ITEM_ACCOUNT_ASSIGNMENT       =
*           PO_ITEM_TEXT                     =
         RETURN                            = RETURN
*           PO_LIMITS                        =
*           PO_CONTRACT_LIMITS               =
*           PO_SERVICES                      =
*           PO_SRV_ACCASS_VALUES             =
*           PO_SERVICES_TEXT                 =
*           PO_BUSINESS_PARTNER              =
*           EXTENSIONIN                      =
*           POADDRDELIVERY                   =
      if PURCHASEORDER <> space.
        commit work.
        ADD 1 TO gd_update.
        it_success-PURCHASEORDER = PURCHASEORDER.
        append it_success.
clear:PO_HEADER,PO_HEADER_ADD_DATA,PURCHASEORDER.
        refresh : PO_ITEMS,PO_ITEM_SCHEDULES,RETURN.
      ELSE.
        loop at return.
          it_error-pono = tab-PO_NUMBER.
          it_error-err_msg = return-MESSAGE .
          Append it_error.
        ENDLOOP.
clear:PO_HEADER,PO_HEADER_ADD_DATA,PURCHASEORDER.
        refresh : PO_ITEMS,PO_ITEM_SCHEDULES,RETURN.
      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) 'Purchase 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-PURCHASEORDER, 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-pono, 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

Similar Messages

  • How can I add photos in the Camera roll to My photo stream if they were taken prior to icloud being activated?

    How can I add photos in the Camera roll to My photo stream if they were taken prior to icloud being activated?

    You have a couple of options:
    Open the photos one at a time and take a screenshot.  This will add a new low resolution copy of the photo to the camera roll, which will then upload to your photo stream;
    Email the photos one at a time to yourself, then save the attached photos to your camera roll.  This will add a copy of the photo at full resolution to your camera roll and upload to photo stream;
    Use an app like PhotoSync, which will allow you to wirelessly transfer copies of all your old photos to your computer all at once.  Then delete these photos from your camera roll and use PhotoSync to transfer them back from your computer to your camera roll.  These will be the original resolution and will upload to your photo stream.  (You need an app like this because iTunes will not transfer photos back to your camera roll, where they must be in order to add to your photo stream.)

  • How can I add attachment files – or photos – to my created Adobe reader XI files?

    How can I add attachment files – or photos – to my created Adobe reader XI files?

    Hi adel ghonim,
    You can add images following the instructions in this Help article: Adobe Acrobat X Standard * Paste images as comments.
    You can also add attachments by clicking the paperclip icon in the left column of the Acrobat window...
    Please let me know if you need further assistance.
    Best,
    Sara

  • I have an apple TV Model A1427 and do not have an icon for youtube. How can I add youtube to the home page?

    I have an apple TV Model A1427 and do not have an icon for youtube. How can I add youtube to the home page?

    Have icon but cannot connect - Please Help.
    Mine is Gen. 2 - Model MC572C/A. I have the YouTube icon but cannot access YouTube.  Message says "No content was found - There is a problem communicating with YouTube. Try again later."  This problem has been for at least 1 month now.  Any ideas?

  • HT4059 how can i add books to the library on my iphone 4s

    How can I add books to the library on my 4s?

    If the photos that you are wanting to delete are also in your Camera Roll then you can delete them from the camera roll

  • Using the value "Image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of preconfigured file types (.jpe, .jpg, .jpeg, .?

    On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
    Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
    <input type="file" name="file" accept="image/*" id="file" />
    mimeTypes.rdf does not seem to allow this.

    ''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
    You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
    <pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
    For details, see
    * [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input]

  • I have an ipod touch and the contacts icon is missing.  How can you add it to the home screen?

    I can't find the contacts icon... How can you add this to the home screen

    Every iPod touch has a contacts icon. It might be hiding. You can try Settings > General > Reset > Reset Home Screen Layout.

  • I currently have a D-Link DI-604 broadband router with windows computers.  How can I add wifi to the network for use with ipad?  Can I use AirPort Express?

    I currently have a D-Link DI-604 broadband router with windows computers.  How can I add wifi to the network for use with ipad?  Can I use AirPort Express?

    Yes. You can directly connect an 802.11n AirPort Express Base Station (AXn) using an Ethernet cable. The AXn would then just need to be configured as a bridge to allow the D-Link to continue to provide both NAT & DHCP services for all network clients connected to either router.
    In this configuration, the AXn would broadcast a wireless network for your wireless network clients to connect to.

  • How can i add subfolders in the mailsystem to classified my mails

    how can i add subfolders in the mailsystem to classified my mails similar to outlook. Somebody with idea?-

    You can't do it directly on the iPad. If your email account is setup as IMAP, create the folders on the server (either in Outlook or webmail) and then the folders will appear in iPad Mail.

  • In the middle of creating a book in aperture I need more photos. How can I add them to the browser at this stage?

    In the middle of creating a book in Aperture I need more photos. How can I add them to the browser at this stage?

    In the middle of creating a book in Aperture I need more photos. How can I add them to the browser at this stage?
    You can add more images to your book, by dragging them from the browser to your book album. Switch to the Library Inspector, select the album or project with the images in the source list, and then drag these images onto the book icon. That will add them to the book album, and then double click the book album again to continue working with the book.
    Regards
    Léonie

  • I have Garage Band for my IPad. I would like to add a "delay" effect to my music, but I do not see that effect available. How can I add it to the software? Thank you.

    Hello all,
    I have Garage Band on my Ipad Mini and I notice that it does not have a "delay effect" that can be added to my music. There are other effects, but no delay, which is the most important one for me. How can I add this effect?  Thank you.

    There are not many effects available in GarageBand on the iPad. You can add reverb and echo to the Master Track, but that's it.
    See the User Guide:  http://help.apple.com/garageband/ipad/1.4/index.html#chs175dc411

  • HT1848 How can I add photos to the iPad while not deleting any currently on it? I have some photos from my brother's camera that I can't get again.  How could save them onto my iMac?

    I have uploaded photos from my brother's camera while on vacation to my iPad (1).  Now that I wish to add even more photos to the iPad,  iTunes say that it will replace all the photos once I sync again to add from an album on the iMac.
    WHOA.
    I'd like to upload the photos to the iMac! HOw can I do that?
    How can I add photos from albums on the iMac and not lose the ones I currently have stored onthe iPad.
    I cannot find this task addressed in any Help reference.
    I do not understand why I cannot make a simple file transfer back and forth.
    Many thanks!

    Another way. You can use a USB flash drive & the camera connection kit.
    Plug the USB flash drive into your computer & create a new folder titled DCIM. Then put your movie/photo files into the folder. The files must have a filename with exactly 8 characters long (no spaces) plus the file extension (i.e., my-movie.mov; DSCN0164.jpg).
    Now plug the flash drive into the iPad using the camera connection kit. Open the Photos app, the movie/photo files should appear & you can import. (You can not export using the camera connection kit.)
    Secrets of the iPad Camera Connection Kit
    http://howto.cnet.com/8301-11310_39-57401068-285/secrets-of-the-ipad-camera-conn ection-kit/
     Cheers, Tom

  • How can I add or change the Network I'D for the TouchPad?

    Most devices on a network have names for the device for one reason or another. This helps to distinguish between connected devices and the legitimacy thereof.
    So far I have been unable to add a Network ID to this TouchPad.
    With the Amazon Kindle Fire had seen the network ID as "My Phone" which I really wanted to change, and fast. Did manage to change it with an Android app called Fing, which allowed me to use a rather unorthodox network identification name.
    Would like to find another network utility that can do the same for the HP TouchPad. Any ideas as to a utility, or a more manual method? Fing via the Kindle Fire shows no network ID for my TouchPad.
    Post relates to: HP TouchPad (WiFi)
    This question was solved.
    View Solution.

    Hello Xelkos,
    What you're talking about is actually a feature of DHCP. When asking for an IP address, a client can send a hostname to the server so that it can be easily identified in a human-readable way.
    By default, this is disabled on the TouchPad. To enable it, you're going to need to edit a text file on the device. There's lots of different ways to do this, so pick your favorite and then follow these insturctions.
    Find /etc/dhclient.conf and open it
    Find the line that starts with:
    # send-hostname
    Delete the "#" sign in front of the line and change the text inside the quotes. This text should be whatever you want your hostname to be:
    send-hostname "TouchPad"
    Once you've done that, save and close the file
    Next, turn Wi-Fi off and then back on. You should now see your hostname show up on your Access Point / Router.
    NOTE: Remember that in order to make these changes permanent, you must set the file system as read-write:
    mount -o remount,rw /
    You must also set it back to read-only when you're done:
    mount -o remount,ro /

  • How can I add hyperlink to the object in iCloud pages ?

    Hi, there
    I want to add hyperlink to the object(image) in icloud pages.
    But it looks no such function on  icloud(any "add link" botton)
    I know that how to add hyperlint to the object in pages v5.2.
    1. place object
    2. prepare text box and add hyperlink to the text(invisible color)
    3. overlay object and textbox
    But, in icloud pages, I coundln't do above method.
    Pls give me some advice.
    Thanks.

    The feature to add images in tables is gone, ike about another 90 features that exists in Pages 09.

  • How can I add roles or features with using WMI?

    Can I add features in Windows server 2008/2012 with using WMI? I found only how to see installed features, but can`t found anything in my question. Can anybody help?

    Hi,
    I agree with Ed’s suggestion. Just in addition, you can install roles, role services, or features via
    Install-WindowsFeature PowerShell cmdlets. Please refer to following TechNet article and check if can help you.
    Install-WindowsFeature
    If any update, please feel free to let us know.
    Hope this helps.
    Best regards,
    Justin Gu

Maybe you are looking for