Write table to SAP (BAPI, ActiveX...)

Hello everybody,
I have to do a SW that interfaces with SAP. I already have functions to login/out, read/write a single parameter, and read a table (all this trough BAPI ActiveX), but I’m not able to write in a SAP table.
Does somebody already have done this job?
Many thanks for any advice!
Pierre-Alain
(LV2010SP1 or 2014SP1, W7, SAP Business Client 3.5)

Many thanks, nyc, mike, for your responses and interest!
I find SAP doc not so easy to transpose into LabVIEW code...
Error happends like this:
Login SAP: OK (work also in other programs)
Add name of the specific BAPI function to be used: OK (work also in other programs)
Input of several single parameters (strings): OK (work also in other programs)
Input of 2 Tables (2x same VI): see code here enclosed. No error at this point. (never tested in other programs)
Call of BAPI function (code tested OK in other programs) but returns an error "SYSTEM_FAILURE"
Reading some return parameters (code tested OK in other programs, but do not works here because of System_Failure)
Close ref and Logoff  (code tested OK in other programs)
I enclose also in this mail an image showing the main VI (named "Créer contenu HU.vi") making all this procedure. You will see that the error comes after the function call.
I'm not a SAP pro (and far away!), but the SAP specialist has tested the BAPI function (with php?) and the function works. So the first suspect code is the one attached here.
Please ask me if you need more details.
Many thanks in advance, best regards,
Pierre-Alain
Attachments:
SAP Write Table.png ‏52 KB
Créer contenu HU.vi.png ‏170 KB

Similar Messages

  • SAP BAPI ActiveX Interface

    Hello,
    This is a cross post from LAVA forum...
    I'm trying to integrate our test stations to SAP ERP. SAP stores data in busines objects in busines object repository. The objects are exposed over BAPI interface. There is a lot of different busines objects in the repository. SAP developers can also build new objects if they want. The objective is to read inspection characeristics from quality management module of SAP. I haven't done much ActiveX stuff, neither know much about SAP, so I started with a simple example that I found searching for BAPI examples. The example works fine in Excel. The example just reads some data from a sales order object.
    Sub BAPI1()Dim
    oBook As Workbook
    Dim oSheet As Worksheet
    Dim oBAPICtrl As Object
    Dim oBAPILogon As Object
    Dim oSalesOrder As Object
    Dim oItem As Object
    Dim iIndex As Integer
    Set oBook = Application.ActiveWorkbook
    Set oSheet = oBook.Worksheets(1)
    ' Initialize SAP ActiveX Control.
    Set oBAPICtrl = CreateObject("sap.bapi.1")
    ' Initialize SAP ActiveX Logon.
    Set oBAPILogon = CreateObject("sap.logoncontrol.1")
    ' Initialize the connection object.
    Set oBAPICtrl.Connection = oBAPILogon.newconnection
    ' Logon with prompt.
    oBAPICtrl.Connection.System = "Q02"
    oBAPICtrl.Connection.Client = 101
    oBAPICtrl.Connection.Logon
    ' Retrieve a sales order.
    Set oSalesOrder = oBAPICtrl.GetSAPObject("SalesOrder","0010732181")
    ' Display Sales Order header data.
    oSheet.Cells(2, 1).Value = oSalesOrder.salesdocument
    oSheet.Cells(2, 2).Value = oSalesOrder.netvalue
    oSheet.Cells(2, 3).Value = oSalesOrder.orderingparty.customerno
    oSheet.Cells(2, 4).Value = oSalesOrder.documentdate
    oSheet.Cells(2, 5).Value = oSalesOrder.items.Count
    ' Logoff SAP and close the control.
    oBAPICtrl.Connection.logoff
    Set oBAPILogon = Nothing
    Set oBAPICtrl = Nothing
    End Sub
     I tried to implement that in LabVIEW. The logon and logout part works, I can also obtain SalesOrder object with GetSAPObject method. There is no error and probing the Object output from GetSAPObject methods gives an integer value - probably a reference to the SalesOrder object.
    Now I can't figure out how do I read the object properties. It's very simple in VBA. I also don't know how do I call object methods. This is apicture from SAP BAPI documentatios showing available properties and methods.
    I would appreciate any hints...
    bye, Mirko

    No, there isn't any reference type that matches BAPI Object. In fact, there can't be a fixed type reference, since BAPI object are actually function modules that SAP programmers write themselves using language called ABAP. I concluded that we can't call the object methods or read/write properties in LabVIEW, if we don't know the right type at development time. So, I gave up on BAPI API.
    There are also other methods of SAP integration. O step down on abstraction scale is Remote Function Call (RFC) API. The API is much more involved, but it allows us to call functions that are behind BAPI objects. In a few test that I did it worked fine. The interface is exposed over three ActiveX controls - SAP Remote Function Call Control, SAP Table Factory Control and SAP Logon Control.
    There is also .NET assembly and web services which I didn't tried.
    Regards, Mirko

  • Read/write table rather than calling BAPI

    Hi experts,
    I need set "Deliv. compl." flag as true .
    set NOMOREGR='X' when call BAPI_GOODSMVT_CREATE
    I want to read/write table rather than calling BAPI, but I don't know what's the table,what's the field.
    who can tell me?  How to find that?
    I pressed "F1" key in the checkbox (Deliv. compl. flag), then I clicked "Technical infomation", and I got "MEPO1313-ELIKZ", but it's a struct, not a table.
    Many thanks.

    I happened to recall something about MEPO from way back when.... and the "EPO" suggested EKPO and EKKO to me...
    However, I utilize WHERE-USED function a lot.  For instance, in this case, one might go into SE11, enter ELIKZ into the data type field, and select WHERE-USED.  This takes a bit of research since field ELIKZ is used often as completion indicator, LOEKZ as deletion indicator, etc.
    Best wishes,
    Dave

  • BAPI activeX con SAP CRM

    ¿Alguien tiene un ejemplo de como hacer una actividad en SAP CRM con las BAPI activex?.
    Más concretamente necesitaría saber cuales son los parámetros que se le pasa al método createmultiple cuando se llama desde otro lenguaje a través de activex.
    Un ejemplo seria algo así:
    bo_sap = iole_bapi.GetSAPObject("ActivityCRM")
    oheader = iole_bapi.DimAs(bo_sap,"CreateMultiple","HEADER")
    oheader.Rows.Add()
    oheader.Value(1,"CATEGORY", "101")
    oheader.Value(1,"PROCESS_TYPE", "Z009")
    oheader.Value(1,"DESCRIPTION", "JJ")
    bo_sap.CreateMultiple(oheader)
    En este último método es donde no me funciona porque no conozco los parámetros que lleva.
    Gracias por adelantado

    RM_MKTPL_BAPI                 CRM Marketing Planning BAPIs,BOR Methods
    API_TRADE_ELMT_EXIST_CHECK    Marketing Planning - Check Existence of Trade Element
    API_TRADE_EXISTENCE_CHECK     Marketing Planning - Check Existence of Trade
    BAPI_CAMPAIGN_ELMT_EXIST_CHECK
    BAPI_CAMPAIGN_EXISTENCE_CHECK
    BAPI_CAMPGN_OBJECT_EXIST_CHECK
    BAPI_DEAL_EXISTENCE_CHECK
    BAPI_MKTPL_PROD_ASSIGN_CREATE
    BAPI_MKTPL_PROD_ASSIGN_DELETE
    BAPI_MKTPL_PROD_ASSIGN_READ
    BAPI_MKT_PLAN_ELMT_EXIST_CHECK
    BAPI_MKT_PLAN_EXISTENCE_CHECK
    BAPI_UPD_TSPEND_REBATE_STAT
    BAPI_TRADE_EXISTENCE_CHECK
    BAPI_TRADE_ELMT_EXIST_CHECK
    BAPI_MKT_PLAN_EXISTENCE_CHECK
    Pl.Reward points...

  • Bad DimAs mapping for Structure Parameters, BAPI ActiveX

    I am using BAPI ActiveX from Visual Basic.  All is working well except a mapping issue.
    I am mapping a BAPI structure export parameter to an object using DimAs method.  I am getting raw byte lengths instead of character lengths.  Example if a parameter is 10 characters long it is actually unicode stored as 20 bytes.
    The result is that the object is misaligned when retrieving data.  So I have to play games to find ask for the right field that will line up.  I am getting the data ok, no extra bytes.  The object fields are defined improperly.
    If the export parameter is a table or a simple value, no problems.  It appears to be structures only.  Note:  I am going after cProjects BAPI's, I have not tested other BAPI areas to see if the same problem exists.
    Known issue?  Any kind of notes I should check out?  Workaround ideas other than the tedious one I have?
    Thanks

    Hi,
    Workout the below application u can get idea abt BAPI,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/creating%20a%20web%20dynpro%20application%20accessing%20abap%20functions.pdf
    1)Input parameter is Input node where we can give some input to access an BAPI.
    2)Output parameter is Output node wher we have all output datas...we import all datas from BAPI to WebDynpro by using Output node
    3)But all Input node have Output node..so we can access output node from Input node.
    Regards,
    Suresh T

  • How to Send Internal table to SAP Spool using Function Modules or Methods?

    Hi Experts,
    How to Send Internal table to SAP Spool using Function Modules or Methods?
    Thanks ,
    Kiran

    This is my code.
    I still get the no ABAP list data for the spool, even tho I can see it sp01?
    REPORT  Z_MAIL_PAYSLIP.
    * Declaration Part *
    tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
    infotypes: 0000, 0001, 0105, 0655.
    data: begin of ITAB occurs 0,
      MTEXT(25) type C,
      PERNR like PA0001-PERNR,
      ABKRS like PA0001-ABKRS,
      ENAME like PA0001-ENAME,
      USRID_LONG like PA0105-USRID_LONG,
    end of ITAB.
    data: W_BEGDA like HRPY_RGDIR-FPBEG,
          W_ENDDA like HRPY_RGDIR-FPEND.
    data: RETURN like BAPIRETURN1 occurs 0 with header line.
    data: P_INFO like PC407,
          P_FORM like PC408 occurs 0 with header line.
    data: P_IDX type I,
          MY_MONTH type T549Q-PABRP,
          STR_MY_MONTH(2) type C,
          MY_YEAR type T549Q-PABRJ,
          STR_MY_YEAR(4) type C,
          CRLF(2) type x value '0D0A'.
    data: W_CMONTH(10) type C.
    data: TAB_LINES type I,
          ATT_TYPE like SOODK-OBJTP.
    data: begin of P_INDEX occurs 0,
            INDEX type I,
    end of P_INDEX.
    constants: begin of F__LTYPE, "type of line
       CMD like PC408-LTYPE value '/:',  "command
       TXT like PC408-LTYPE value 's',   "textline
    end of F__LTYPE.
    constants: begin of F__CMD, "commands
      NEWPAGE like PC408-LINDA value '',
    end of F__CMD.
    data: P_LIST like ABAPLIST occurs 1 with header line.
    *data: OBJBIN like SOLISTI1 occurs 10 with header line,
    data: OBJBIN like  LVC_S_1022 occurs 10 with header line,
          DOCDATA like SODOCCHGI1,
          OBJTXT like SOLISTI1 occurs 10 with header line,
          OBJPACK like SOPCKLSTI1 occurs 1 with header line,
          RECLIST like SOMLRECI1 occurs 1 with header line,
          OBJHEAD like SOLISTI1 occurs 1 with header line,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_buffer type string,
          l_no_of_bytes TYPE i,
          l_pdf_spoolid LIKE tsp01-rqident,
          l_jobname     LIKE tbtcjob-jobname.
    data: file_length  type int4,
          spool_id     type rspoid,
          line_cnt     type i.
    *-------------------------------------------------------------------* * INITIALIZATION *
    OBJBIN = ' | '.
    append OBJBIN.
    OBJPACK-HEAD_START = 1.
    data: S_ABKRS like PV000-ABKRS.
    data: S_PABRP like T549Q-PABRP.
    data: S_PABRJ like T549Q-PABRJ.
    * SELECTION SCREEN                                                  *
    selection-screen begin of block BL1.
    parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
    selection-screen end of block BL1.
    START-OF-SELECTION.
      s_ABKRS = PNPXABKR.
      S_PABRP = PNPPABRP.
      s_pabrj = PNPPABRJ.
      w_begda = PN-BEGDA.
      w_endda = PN-ENDDA.
    get pernr.
    *                                 "Check active employees
      rp-provide-from-last p0000 space pn-begda  pn-endda.
      CHECK P0000-STAT2 IN PNPSTAT2.
    *                                 "Check Payslip Mail flag
      rp-provide-from-last p0655 space pn-begda  pn-endda.
      CHECK P0655-ESSONLY = 'X'.
      rp-provide-from-last p0001 space pn-begda  pn-endda.
    *                                 "Find email address
      RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
      if p0105-usrid_LONG ne ''.
        ITAB-PERNR      = P0001-PERNR.
        ITAB-ABKRS      = P0001-ABKRS.
        ITAB-ENAME      = P0001-ENAME.
        ITAB-USRID_LONG = P0105-USRID_LONG.
        append itab.
        clear itab.
      endif.
      "SY-UCOMM ='ONLI'
    END-OF-SELECTION.
    *------------------------------------------------------------------* start-of-selection.
      write : / 'Payroll Area        : ', S_ABKRS.
      write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
      write : / 'System Time         : ', SY-UZEIT.
      write : / 'User Name           : ', SY-UNAME.
      write : / SY-ULINE.
      sort ITAB by PERNR.
      loop at ITAB.
        clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
        refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
    *                                                  Retrieve Payroll results sequence number for this run
        select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
                                        and FPBEG ge W_BEGDA
                                        and FPEND le W_ENDDA
                                        and SRTZA eq 'A'.
    *                                                  Produce payslip for those payroll results
        if SY-SUBRC = 0.
          call function 'GET_PAYSLIP'
            EXPORTING
              EMPLOYEE_NUMBER = ITAB-PERNR
              SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
              PAYSLIP_VARIANT = PAY_VAR
            IMPORTING
              RETURN          = RETURN
              P_INFO          = P_INFO
            TABLES
              P_FORM          = P_FORM.
          check RETURN is initial.
    *                                                 remove linetype from generated payslip
          loop at p_form.
            objbin = p_form-linda.
            append objbin.
            line_cnt = line_cnt + 1.
          endloop.
          file_length = line_cnt * 1022.
    *                                                 create spool file of paylsip
          CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
            EXPORTING
              i_file_length = file_length
            IMPORTING
              e_spoolid     = spool_id
            TABLES
              it_textdata   = objbin.
          IF sy-subrc EQ 0.
            WRITE spool_id.
          ENDIF.
          DESCRIBE table objbin.
          DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
          CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
            EXPORTING
              SRC_SPOOLID                    = spool_id
              NO_DIALOG                      = ' '
              DST_DEVICE                     = 'MAIL'
    *      PDF_DESTINATION                =
    *    IMPORTING
    *      PDF_BYTECOUNT                  = l_no_of_bytes
    *      PDF_SPOOLID                    = l_pdf_spoolid
    *      LIST_PAGECOUNT                 =
    *      BTC_JOBNAME                    =
    *      BTC_JOBCOUNT                   =
            TABLES
              PDF                            = pdf
            EXCEPTIONS
              ERR_NO_ABAP_SPOOLJOB           = 1
              ERR_NO_SPOOLJOB                = 2
              ERR_NO_PERMISSION              = 3
              ERR_CONV_NOT_POSSIBLE          = 4
              ERR_BAD_DESTDEVICE             = 5
              USER_CANCELLED                 = 6
              ERR_SPOOLERROR                 = 7
              ERR_TEMSEERROR                 = 8
              ERR_BTCJOB_OPEN_FAILED         = 9
              ERR_BTCJOB_SUBMIT_FAILED       = 10
              ERR_BTCJOB_CLOSE_FAILED        = 11
              OTHERS                         = 12
          IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    *Download PDF file C Drive
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = 'C:\itab_to_pdf.pdf'
          filetype = 'BIN'
        TABLES
          data_tab = pdf.
    * Transfer the 132-long strings to 255-long strings
    *  LOOP AT pdf.
    *    TRANSLATE pdf USING ' ~'.
    *    CONCATENATE gd_buffer pdf INTO gd_buffer.
    *  ENDLOOP.
    *  TRANSLATE gd_buffer USING '~ '.
    *  DO.
    *    it_mess_att = gd_buffer.
    *    APPEND it_mess_att.
    *    SHIFT gd_buffer LEFT BY 255 PLACES.
    *    IF gd_buffer IS INITIAL.
    *      EXIT.
    *    ENDIF.
    *  ENDDO.
          OBJHEAD = 'Objhead'.
          append OBJHEAD.
    * preparing email subject
          concatenate W_ENDDA(6)
                    ' Payslip-'
                    ITAB-ENAME+0(28)
                    ITAB-PERNR+4(4) ')'
                 into DOCDATA-OBJ_DESCR.
          DOCDATA-OBJ_NAME = 'Pay Slip'.
          DOCDATA-OBJ_LANGU = SY-LANGU.
          OBJTXT = 'Pay Slip.'.
          append OBJTXT.
    *prepare email lines
          OBJTXT = DOCDATA-OBJ_DESCR.
          append OBJTXT.
          OBJTXT = 'Please find enclosed your current payslip.'.
          append OBJTXT.
    * Write Attachment(Main)
    * 3 has been fixed because OBJTXT has fix three lines
          read table OBJTXT index 3.
    *    DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
          clear OBJPACK-TRANSF_BIN.
          OBJPACK-HEAD_START = 1.
          OBJPACK-HEAD_NUM = 0.
          OBJPACK-BODY_START = 1.
          OBJPACK-BODY_NUM = 3.
          OBJPACK-DOC_TYPE = 'RAW'.
          append OBJPACK.
    * Create Message Attachment
          ATT_TYPE = 'PDF'.
          describe table OBJBIN lines TAB_LINES.
          read table OBJBIN index TAB_LINES.
    *    OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
          OBJPACK-TRANSF_BIN = 'X'.
          OBJPACK-HEAD_START = 1.
          OBJPACK-HEAD_NUM = 0.
          OBJPACK-BODY_START = 1.
          OBJPACK-BODY_NUM = TAB_LINES.
          OBJPACK-DOC_TYPE = ATT_TYPE.
          OBJPACK-OBJ_NAME = 'ATTACHMENT'.
          OBJPACK-OBJ_DESCR = 'Payslip'.
          append OBJPACK.
    * Create receiver list refresh RECLIST.
          clear RECLIST.
          RECLIST-RECEIVER = itab-USRID_long.
          translate RECLIST-RECEIVER to lower case.
          RECLIST-REC_TYPE = 'U'.
          append RECLIST.
    * Send the document
    *SO_NEW_DOCUMENT_ATT_SEND_API1
          call function 'SO_DOCUMENT_SEND_API1'
            exporting
              DOCUMENT_DATA = DOCDATA
              PUT_IN_OUTBOX = 'X'
              COMMIT_WORK = 'X'
    * IMPORTING
    *   SENT_TO_ALL =
    *   NEW_OBJECT_ID =
            tables
              PACKING_LIST  = OBJPACK
              OBJECT_HEADER = OBJHEAD
              CONTENTS_BIN  = pdf
              CONTENTS_TXT  = OBJTXT
    *   CONTENTS_HEX =
    *   OBJECT_PARA =
    *   OBJECT_PARB =
              RECEIVERS = RECLIST
            exceptions
              TOO_MANY_RECEIVERS = 1
              DOCUMENT_NOT_SENT = 2
              DOCUMENT_TYPE_NOT_EXIST = 3
              OPERATION_NO_AUTHORIZATION = 4
              PARAMETER_ERROR = 5
              X_ERROR = 6
              ENQUEUE_ERROR = 7
              others = 8.
          if SY-SUBRC NE 0.
            ITAB-MTEXT = 'Message Not Sent to : '.
          else.
            ITAB-MTEXT = 'Message Sent to : '.
          endif.
    *    else.
    *      ITAB-MTEXT = 'Message Not Sent to : '.
    *    endif.
        else.
          "SY-SUBRC Not = 0
          ITAB-MTEXT = 'Payroll data not found : '.
        endif.
        "end of SY-SUBRC = 0.
        modify ITAB.
      endloop. "end loop at ITAB
      sort ITAB by MTEXT PERNR.
      loop at ITAB.
        at new MTEXT.
          uline.
          write : / ITAB-MTEXT color 4 intensified on.
          write : / 'Emp. Code' color 2 intensified on,
                 12 'Emp. Name' color 2 intensified on,
                 54 'Email ID' color 2 intensified on.
        endat.
        write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
      endloop.

  • How to copy the Data From Oracle Table To SAP Table

    Hi Friends,
    We need to copy the data from Oracle Database Table to SAP Table. The data should be updated simultaneously in both tables . Should I write a program that contains the native sql statement like EXEC SQL PERFORMING WRITE,....
    I appreciate any suggestions regarding this.
    Regards
    CSM Reddy

    Hi,
    since you posted this question in the DB2 forum I assume that you are using a DB2 database for your SAP system.
    To access a table from a legacy ORACLE database you may use the DBSL multiconnect feature. I.e. you open a secondary connecction in the SAP system to your ORALE database. You can then ready the data from the ORACLE database into an ABAP internal table and insert it afterwards into the DB2 table on the main connection.
    Another way to access an ORACLE table from a DB2 database is to use the DB2 federated database feature. This requires a little bit more DB2 skill. With this feature you can make the ORACLE table visible within the DB2 database. To copy data you can then simply use a "INSERT ... SELECT" statement. 
    Regards
             Frank

  • How to retrieve the data from SAP-BAPI by using VB Code

    Hi ,
    I am new to BAPI.
    V have created an application in Visual Basic with the following fields
    EmpNo , EmpName, Addr1, Addr2, City and Phone (Only for Test)
    We have written the code for SAVING the data into SAP. Already we have
    constructed a table with the respective fields in SAP.
    For that we ourself created our own BAPI Structure / Function Group /
    Function Module/ Business Object - RELEASED related elements.
    1)Established the connection successfully.
    2)Stored the data into SAP Successfully and v r in need of
    3)HOW TO RETRIEVE THE DATA FROM SAP (USING GETLIST.....GETDETAIL....)
    Following is the code :
    'BAPI Structure  : ZBAPIEMP
    'Function Group  : ZBAPIEMP
    'Function Module : ZBAPI_EMP_CREATEFROMDATA
    'Business Object : ZBAPIEMP
    'Function Module : ZBAPI_EMP_GETLIST
    Dim bapictrl As Object
    Dim oconnection As Object
    Dim boEmp As Object
    Dim oZEmp_Header As Object
    Dim oImpStruct As Object
    Dim oExpStruct As Object
    Dim oreturn As Object
    Dim x As String
    Private Sub Form_Load()
    Set bapictrl = CreateObject("SAP.BAPI.1")
    Set oconnection = bapictrl.Connection
    oconnection.logon
    Set boEmp = bapictrl.GetSAPObject("ZBAPIEMP")
    Set oZEmp_Header = bapictrl.DimAs(boEmp, "CreateFromData", "EmployeeHeader")
    Set oImpStruct = bapictrl.DimAs(boEmp, "GetList", "EmployeeDispStruct")
    End Sub
    Private Sub cmdSave_Click()
        oZEmp_Header.Value("EMPNO") = txtEmpNo.Text
        oZEmp_Header.Value("EMPNAME") = txtEmpName.Text
        oZEmp_Header.Value("ADDR1") = txtAddr1.Text
        oZEmp_Header.Value("ADDR2") = txtAddr2.Text
        oZEmp_Header.Value("CITY") = txtCity.Text
        oZEmp_Header.Value("PHONE") = txtPhone.Text
        boEmp.CreateFromData EmployeeHeader:=oZEmp_Header, Return:=oreturn
        x = oreturn.Value("Message")
        If x = "" Then
            MsgBox "Transaction Completed!..."
        Else
            MsgBox x
        End If
    End Sub
    Private Sub cmdView_Click()
    End Sub
    COULD ANYBODY GUIDE ME, HOW TO RETRIEVE THE DATA FROM BAPI, FOR THE WRITTEN CODE.

    I didn't seen any other answers but here's how it's been done previously in our organization for a custom BAPI. In this example, we give material and language to return the part description. It's not specific to your project but may give you ideas..
    -Tim
    Option Compare Database
    Dim SAPLOGIN As Boolean
    Dim FunctionCtrl As Object
    Dim SapConnection As Object
    Sub SAPLOGOUT()
    On Error GoTo LogoutFehler
        SapConnection.logoff
        SAPLOGIN = False
    Exit Sub
    LogoutFehler:
        If Err.Number = 91 Then
            Exit Sub
        Else
            MsgBox Err.Description, vbCritical, "Fehler-Nr." & CStr(Err.Number) & " bei SAP-Logout"
        End If
    End Sub
    Function SAPLOG() As Boolean
    'Verbindungsobjekt setzen (Property von FunctionCtrl)
       Set FunctionCtrl = CreateObject("SAP.Functions")
       Set SapConnection = FunctionCtrl.Connection
    'Logon mit Initialwerten
       SapConnection.Client = "010"
       SapConnection.Language = "EN"
       SapConnection.System = "PR1"
       SapConnection.SystemNumber = "00"
       'SapConnection.Password = ""
       SapConnection.GroupName = "PR1"
       SapConnection.HostName = "168.9.25.120"
       SapConnection.MessageServer = "168.9.25.120"
         If SapConnection.Logon(0, False) <> True Then  'Logon mit Dialog
             Set SapConnection = Nothing
             DoCmd.Hourglass False
             MsgBox "No connection to SAP R/3 !"
             SAPLOGIN = False
             SAPLOG = False
             Exit Function
          End If
        SAPLOG = True
    End Function
    Function MatDescr(MatNr As String)
    Dim func1 As Object
    Dim row As Object, X As Integer, ErsteNr As String
    Dim DatensatzZähler As Long
    Dim RowField(1 To 50, 0 To 1) As String, RowLine As Long
        If Not SAPLOGIN Then
            If Not SAPLOG() Then
                MsgBox "No connection  to SAP !", 16
                SAPLOGOUT
                Exit Function
            End If
        End If
    ' Instanziieren des Function-Objektes
    Set func1 = FunctionCtrl.Add("Z_BAPI_READ_MAKT")
    ' Export-Paramter definieren
    func1.exports("MATNR") = MatNr
    func1.exports("SPRAS") = "EN"
    DoEvents
    If Not func1.call Then
        If func1.exception <> "" Then
            MsgBox "Communication Error with RFC " & func1.exception
        End If
        DoCmd.Hourglass False
        SAPLOGOUT
        Exit Function
    Else
      MatDescr = func1.imports("MAKTX")
    End If
    If MatDescr = "" Then
        MatDescr = "PART NO. NOT FOUND"
    End If
    End Function

  • Write Table to Excel

    I have taken the write table to xl.vi example and modified it so that I can use it. Write now I have a vi setup that displays certain columns of data that I am pulling from a txt file in both a graph and a table. Then I am trying to write this table to xl by following the example, however I get the error 97 when running the vi, and a blank excel workbook opens up. I think this has something to do with how the table I have created is used to try and enter this into excel. Any help you can provide would be greatly appreciated. Thanks.
    Attachments:
    Data_Display_2.vi ‏134 KB

    Error 97 is "LabVIEW: Null Refnum was passed in as input."
    You might wanna check whether the Automation Refnum is linked to the correct ActiveX class in the "Open Excel" VI.
    In your diagram, as Dennis pointed out, it has no dataflow. The row header and column header in your table are both empty as well. That results in three for-loops doing nothing. Wire your "Hour" variable directly to the input of the third loop instead. Also at the end of the program, you should close all opened references regardless of the "Completion Task". Put only the invoke node "application quit" in the case structure should do.
    Hope this helps.
    Dan

  • How to Access oracle DB table through SAP..problem in code

    Hello Guys
             I have to Access oracle table through SAP and need to create a report.
    From Some source I got the following code .  But it's not working , I am not able to update the table as well not able to access the data from table.
    Can some one provide me the necessary help.
    REPORT  ZORACLE.
    INCLUDE ole2incl.
    DATA: con TYPE ole2_object,
    rec TYPE ole2_object.
    DATA SQL(1023).
    DATA: BEGIN OF SPL OCCURS 0,
    VAL(1023),
    END OF SPL.
    DATA: BEGIN OF I1 OCCURS 0,
    F1(10) ,
    F2 TYPE I,
    END OF I1.
    IF con-header IS INITIAL OR con-handle = -1.
    CREATE OBJECT con 'ADODB.Connection'.
    IF NOT sy-subrc = 0.
    EXIT.
    ENDIF.
    CREATE OBJECT REC 'ADODB.Recordset'.
    IF NOT sy-subrc = 0.
    EXIT.
    ENDIF.
    ENDIF.
    MDB connetion infomations ....
    break-point.
    CONCATENATE 'Provider=' '''OraOLEDB.Oracle''' ';'
    INTO SQL.
    CONCATENATE SQL 'Password=' '''prodx''' ';'
    INTO SQL.
    CONCATENATE SQL 'User ID=' '''prod''' ';'
    INTO SQL.
    CONCATENATE SQL 'Data Source=' '''sterlite''' ';'
    INTO SQL.
    CONCATENATE SQL 'Mode=' '''Share Deny None'''
    INTO SQL.
    MDB connection ...
    CALL METHOD OF CON 'Open'
    EXPORTING #1 = SQL.
    Query (insert) statement ...
    SQL = 'insert into ofusers values('.
    CONCATENATE SQL '''Atul''' ',' '''121''' ')' INTO SQL.
    Query run ...
    CALL METHOD OF REC 'Open'
    EXPORTING #1 = SQL
    #2 = CON
    #3 = '1'.
    Query (select) statement ...
    SQL = 'select * from ofusers'.
    Query run ...
    CALL METHOD OF REC 'Open'
    EXPORTING #1 = SQL
    #2 = CON
    #3 = '1'.
    Selecting MDB record into SAP internal table ...
    DO.
        CALL METHOD OF REC 'getstring' = SQL
        EXPORTING #1 = '2' "Do not modify!
        #2 = 1 "Do not modify!
        #3 = '|' "Do not modify!
        #4 = '|'. "Do not modify!
        IF sy-SUBRC EQ 0.
            REFRESH SPL. CLEAR SPL.
            SPLIT SQL AT '|' INTO TABLE SPL.
            LOOP AT SPL.
              CASE SY-TABIX.
                WHEN 1.
                  I1-F1 = SPL-VAL.
                WHEN OTHERS.
                  I1-F2 = SPL-VAL.
              ENDCASE.
            ENDLOOP.
              APPEND I1. CLEAR I1.
            ELSE.
              EXIT.
        ENDIF.
    ENDDO.
    Result writing ...
    LOOP AT I1.
      WRITE: AT /1(10) I1-F1,
      AT (10) I1-F2.
    ENDLOOP.
    connetion close & destroy
    FREE OBJECT con.
    FREE OBJECT rec.
    Thanks in Advance
    Swati Namdeo

    Hi swati,
    1. for this u will also require help of basis team.
    2. these are the steps.
    a) make an entry in DBCON
    b) make connection string
    (on the physical application server,
    so that it can connect to secondary database)
    (this will be done by basis team,
    in which, they will specify the
    IP address of the secondary database server,
    the DATABASE ID, and the port number)
    c) then using open sql / native sql,
    we can use the secondary database connection,
    just like normal.
    d) if we use open sql,
    then there must be Y/Z table on
    sap as well as secondary database,
    and the field names , their type all should be identical.
    regards,
    amit m.

  • Transport table entries sap to sap using rfc

    Hi Guru's,
               I want to write a program for update one table entries of sap system  to onother table of sap system using RFC establishment.
    If you have any example code kindly give it to me.
    Thanks & Regards,
    Lakshman.annamaneni

    Hi,
    POST - 1
    Fisrt create RFC Destination in SM59 between sender & receiver system.
    *Sender System:*
    FUNCTION XX_RFC_READ_SPFLI.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(CARRID) LIKE  SPFLI-CARRID
    *"     VALUE(CONNID) LIKE  SPFLI-CONNID
    *"  EXPORTING
    *"     VALUE(EX_SPFLI) LIKE  SPFLI STRUCTURE SPFLI
    *"     VALUE(SYS) LIKE  SY-SYSID
    *"  EXCEPTIONS
    *"      INVALID_DATA
      SELECT SINGLE * FROM spfli INTO spfli_workarea
             WHERE  carrid      = carrid
             AND    connid      = connid.
      IF sy-subrc EQ 0.
        ex_spfli = spfli_workarea.
      ELSE.
        RAISE invalid_data.
      ENDIF.
      Sys   = sy-sysid.
    ENDFUNCTION.
    *NEXT: create a Prog.*
    REPORT XX_RFC_Tutorial.
    Global Data Declaration
    TABLES: spfli.
    PARAMETERS: p_carrid LIKE spfli-carrid DEFAULT 'LH',
                p_connid LIKE spfli-connid DEFAULT '400'.
    DATA: SYSTEM LIKE SY-SYSID.
    * Calling the Function
    CALL FUNCTION 'XX_RFC_READ_SPFLI'
       EXPORTING
             carrid       =  p_carrid
             connid       =  p_connid
       IMPORTING
             ex_spfli     =  spfli
             sys          =  system
       EXCEPTIONS
             invalid_data =  1.
    * Handling Exceptions
    CASE sy-subrc.
       WHEN 1.
          WRITE 'No data available'.
           EXIT.
    ENDCASE.
    * Displaying Results
    WRITE: spfli-carrid,
           spfli-connid,
           spfli-cityfrom,
           spfli-cityto,
           spfli-deptime,
           spfli-arrtime.
    See the next post for Receiver System:
    Anil.

  • Write Table to XL sample

    Greetings to all NI application engineers and programming experts.
    I have downloaded a write table to XL spreadsheet from the labview example. This sample added a new sheet to the existing file whenever a new table of data is transferred. If I want to save the new data again and again on the same worksheet, how could I do it? Sincerely hope that anyone could help me modify this sample to cater to the above needs as I do not have knowledge with ActiveX property and methods control. Thanks a lot.  
    Attachments:
    Write Table To XL sample.vi ‏107 KB

    Hello Everybody
    I have an opposite problem I donnot want my data to be erased when loops reinitialize/go around for second time. Please let me know of some appropriate modifications for my vi.
    Attachments:
    presure transducer labview measurement'v'.del.vi ‏285 KB

  • How to back up a table in  SAP?Is there tcode to use?

    How to back up a table in  SAP?Is there tcode to use?
    Please suggest me.
    Sai.

    Hello Sai
    I do not think there is a specific "backup" transaction available.
    For the purpose of backing up a couple of customer tables I used the following approach:
    (1) Create a workbench request with all required tables (object entries: R3TR TABU <name of table>; key: '' for client-independent or '<client>' for client-dependent tables.
    Export the request.
    (2) Write a report which creates a new workbench request and copies the object list of (1) to this new request. Finally the request is released.
    (3) Schedule the report as daily batch job. Thus, your latest backup is less than 24 hours old.
    The nice thing about this approach is that if you need to backup additional tables: just add the object entries and keys to the request in (1). No changes are required in (2) or (3).
    Regards
       Uwe

  • BAPI-VB, Unable to call method GetDetail of USER Object using SAP.BAPI.1

    Hi,
    I am trying to call SAP Methods using Excel VBA.
    In the below example, I am trying to get the user details.
    I can solve this, if I use SAP.Functions object, but not when I use SAP.BAPI.1 object.
    The Procedure GetUserDetails() works fine, but the 2nd one GetUserDetails2() fails?
    Can you tell what is the difference in calling SAP method with SAP.Functions and SAP.BAPI.1 ?
    Also how can I run the program GetDetails2() using SAP.BAPI.1
    Const CNT_STR_USR As String = "XXXXX"
    Const CNT_STR_PWD As String = "XXXXX"
    Const CNT_STR_APPLN_SRVR As String = "ides47"
    Const CNT_STR_SYSTEM As String = "IDS"
    Const CNT_STR_SYS_NUM As String = "00"
    Const CNT_STR_CLIENT As String = "800"
    Const CNT_STR_LOGON_LANG As String = "EN"
    Const CNT_STR_LOG_FILE As String = "C:sap_vb.txt"
    Const CNT_INT_LOG_LEVEL As Integer = 9
    'Works Fine
    Public Sub GetUserDetails()
    'Using SAP Functions
    Dim obSAPFn As Object
    Dim obFuncUsrDtl As Object
    Dim obFuncRtrn As Object
    Dim obFuncLogDtl As Object
    Dim sRetStatus As String * 1, sErrText As String, sUsrGroup As String * 12
    Dim iRetRowCount As Integer, iLoop As Integer
    Dim bErrFlag As Boolean
    'Set obSAPFn = New SAPFunctions
    Set obSAPFn = CreateObject("SAP.Functions")
    obSAPFn.Connection.ApplicationServer = CNT_STR_APPLN_SRVR
    obSAPFn.Connection.SystemNumber = CNT_STR_SYS_NUM
    obSAPFn.Connection.User = CNT_STR_USR
    obSAPFn.Connection.Password = CNT_STR_PWD
    obSAPFn.Connection.Language = CNT_STR_LOGON_LANG
    obSAPFn.Connection.Client = CNT_STR_CLIENT
    obSAPFn.LogLevel = CNT_INT_LOG_LEVEL
    obSAPFn.LogFileName = CNT_STR_LOG_FILE
    'Check For Connection
    If obSAPFn.Connection.Logon(0, True) = False Then
        MsgBox "R/3 connection failed"
    Exit Sub
    Else
        If obSAPFn.Connection.IsConnected Then
    '    MsgBox "Connected"
        Else
        MsgBox "Not COnnected"
        Exit Sub
        End If
    End If
    'Get User Details.
    Set obFuncUsrDtl = obSAPFn.Add("BAPI_USER_GET_DETAIL")
    obFuncUsrDtl.Exports("USERNAME") = CNT_STR_USR
    obFuncUsrDtl.Call
    Set obFuncRtrn = obFuncUsrDtl.Tables("RETURN")
    iRetRowCount = obFuncRtrn.RowCount
    bErrFlag = False
    For iLoop = 1 To iRetRowCount
        If obFuncRtrn(iLoop, "TYPE") = "E" Then
    '        ErrorUsuario = True
            sErrText = "E" & obFuncRtrn(iLoop, "ID") & obFuncRtrn(iLoop, "NUMBER") & _
                         " " & obFuncRtrn(iLoop, "MESSAGE")
            MsgBox sErrText
            bErrFlag = True
            Exit For
        End If
    Next
    If bErrFlag = False Then
    Set obFuncLogDtl = obFuncUsrDtl.Imports("LOGONDATA")
    sUsrGroup = obFuncLogDtl("CLASS")
    MsgBox sUsrGroup
    End If
    Set obFuncRtrn = Nothing
    Set obFuncLogDtl = Nothing
    Set obFuncUsrDtl = Nothing
    obSAPFn.Connection.LogOff
    Set obSAPFn = Nothing
    End Sub
    ' Does not work
    Public Sub GetUserDetails2()
    'Using BAPI Object
    Dim obSapBAPICtrl As Object 'BAPI control object
    'Dim obSAPConn As Object 'Connection object
    Dim obSAPUSER As Object ' To Get Details of USER Object
    Dim obLogondata As Object, obDefaults As Object, obAddress As Object, obCompany As Object
    Dim obSnc As Object, obParameter As Object, obProfiles As Object, obActivitygroups As Object
    Dim obReturn As Object, obAddComrem As Object, obAddRml As Object, obAddPag As Object
    Dim obAddUri As Object, obAddSsf As Object, obAddPrt As Object, obAddRfc As Object
    Dim obAddX400 As Object, obAddSmtp As Object, obAddTlx As Object, obAddTtx As Object
    Dim obAddTel As Object, obAddFax As Object, obParameter1 As Object
    Dim sRetStatus As String * 1, sTransId As String, sUsrGroup As String
    Dim iRetRowCount As Integer, iLoop As Integer
    Set obSapBAPICtrl = CreateObject("SAP.BAPI.1")
    obSapBAPICtrl.Connection.ApplicationServer = CNT_STR_APPLN_SRVR
    obSapBAPICtrl.Connection.SystemNumber = CNT_STR_SYS_NUM
    obSapBAPICtrl.Connection.User = CNT_STR_USR
    obSapBAPICtrl.Connection.Password = CNT_STR_PWD
    obSapBAPICtrl.Connection.Language = CNT_STR_LOGON_LANG
    obSapBAPICtrl.Connection.Client = CNT_STR_CLIENT
    obSapBAPICtrl.LogLevel = CNT_INT_LOG_LEVEL
    obSapBAPICtrl.LogFileName = CNT_STR_LOG_FILE
    'Don't show the logon details
    'Connect to SAP
    If obSapBAPICtrl.Connection.Logon(0, True) = False Then
        MsgBox "R/3 connection failed"
        Exit Sub
    Else
        If obSapBAPICtrl.Connection.IsConnected Then
    '    MsgBox "Connected"
        Else
        MsgBox "Not COnnected"
        Exit Sub
        End If
    End If
    ‘Could not find a way to pass the User Id?
    ‘ Is this the right way to pass the user Id for this Object?
    Set obSAPUSER = obSapBAPICtrl.GetSAPObject("USER", CNT_STR_USR)
    Set obLogondata = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Logondata")
    Set obDefaults = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Defaults")
    Set obAddress = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Address")
    Set obCompany = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Company")
    Set obSnc = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Snc")
    Set obParameter = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Parameter")
    Set obProfiles = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Profiles")
    Set obActivitygroups = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Activitygroups")
    Set obReturn = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Return")
    Set obAddComrem = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddComrem")
    Set obAddRml = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddRml")
    Set obAddPag = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddPag")
    Set obAddUri = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddUri")
    Set obAddSsf = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddSsf")
    Set obAddPrt = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddPrt")
    Set obAddRfc = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddRfc")
    Set obAddX400 = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddX400")
    Set obAddSmtp = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddSmtp")
    Set obAddTlx = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddTlx")
    Set obAddTtx = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddTtx")
    Set obAddTel = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddTel")
    Set obAddFax = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "AddFax")
    Set obParameter1 = obSapBAPICtrl.DimAs(obSAPUSER, "GetDetail", "Parameter1")
    sTransId = obSapBAPICtrl.CreateTransactionID()
    'obSapBAPICtrl.TransactionId = sTransId
    obSAPUSER.GetDetail Logondata:=obLogondata, Defaults:=obDefaults, Address:=obAddress, _
    Company:=obCompany, Snc:=obSnc, Parameter:=obParameter, Profiles:=obProfiles, _
    Activitygroups:=obActivitygroups, Return:=obReturn, AddComrem:=obAddComrem, _
    AddRml:=obAddRml, AddPag:=obAddPag, AddUri:=obAddUri, AddSsf:=obAddSsf, _
    AddPrt:=obAddPrt, AddRfc:=obAddRfc, AddX400:=obAddX400, AddSmtp:=obAddSmtp, _
    AddTlx:=obAddTlx, AddTtx:=obAddTtx, AddTel:=obAddTel, AddFax:=obAddFax, _
    Parameter1:=obParameter
    iRetRowCount = obReturn.RowCount
    If iRetRowCount > 0 Then
        For iLoop = 0 To iRetRowCount
            sRetStatus = obReturn(iLoop, "TYPE")
            If sRetStatus = "S" Then
            sUsrGroup = obLogondata("CLASS")
            MsgBox sUsrGroup
            End If
        Next
    End If
    Set obSAPUSER = Nothing
    obSapBAPICtrl.Connection.LogOff
    'Set obSAPConn = Nothing
    Set obSapBAPICtrl = Nothing
    End Sub
    Regards,
    Vikas

    The problem was occuring because, the structure Return was not holding any values.
    But the other tables which returned values were getting populated.
    Regards,
    Vikas

  • Internal table in sap script

    Hello All ,
    I  have got a internal table with tracking numbers and I want to print all the numbers in that internal table on sap script.
    Please advise.
    Thanks
    Moderator message:  please search for available information before asking.
    locked by: Thomas Zloch on Sep 13, 2010 1:09 PM

    Hi,
    You can create a sub-routine and pass all the table entries in variables and then you can print them.

Maybe you are looking for