Quantcast
Channel: SCN : All Content - Scripting Languages
Viewing all 522 articles
Browse latest View live

Help!!! SAP report extraction through pdf(Print Option) using Macro

$
0
0

Hi,

 

Please someone could help me in extracting one of SAP report using Print option(spooling) using Macro. I have recorded a macro for print, giving the destination as "LOCL" and I get a popup "Save PDF File As" dialog box which does not run in Macro. The Macro runs only upto LOCL printer selection. I want a Macro to run even when the prompt for "Save PDF File As" dialog box with the directory and file name to be picked from excel and saves automatically in the directory choosen... Please someone could help me with the code for it?

 

TIA

Merci


How to use actual SAP NetWeaver RFC Library with Python - Execute ABAP Report

$
0
0

Hello community,

 

I presented until now in the series "How to use actual SAPNetWeaver RFC Library with Pyhton" :

 

Here now an example how to define and run ABAP code from Python.

All constants, structures and prototypes are in the quasi-include file sapnwrfc.py - you find it below.

The ABAP report itself is an array of strings. We use the function module (FM) RFC_ABAP_INSTALL_AND_RUN to implement and execute the ABAP program. We set the report line by line in the PROGRAM table of the FM, invoke the function and get a result back in the WRITES table. We read each line of ZEILE and add it to a Result string.

 

# -*- coding: iso-8859-15 -*-
#-Begin-----------------------------------------------------------------

 

 

#-Include---------------------------------------------------------------
FileName = "sapnwrfc.py"
exec(compile(open(FileName).read(), FileName, "exec"))

 

#-Main------------------------------------------------------------------

 

#-Connection parameters-------------------------------------------------
RfcConnParams[0].name = "ASHOST"; RfcConnParams[0].value = "NSP"
RfcConnParams[1].name = "SYSNR" ; RfcConnParams[1].value = "00"
RfcConnParams[2].name = "CLIENT"; RfcConnParams[2].value = "001"
RfcConnParams[3].name = "USER"  ; RfcConnParams[3].value = "BCUSER"
RfcConnParams[4].name = "PASSWD"; RfcConnParams[4].value = "minisap"

 

#-ABAPReport------------------------------------------------------------
#-
#- Code your ABAP report here. The length of each line must be equal or
#- less than 72 characters.
#-
#-----------------------------------------------------------------------
ABAP=[]
ABAP.append("Report zTest Line-Size 256.")
ABAP.append("Write: 'Hello World from'.")
ABAP.append("Write: sy-sysid.")

 


hRFC = SAP.RfcOpenConnection(RfcConnParams, 5, RfcErrInf)
if hRFC != None:

 

  charBuffer = create_unicode_buffer(256 + 1)
  Result = ""

 

  hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_ABAP_INSTALL_AND_RUN", \
    RfcErrInf)

  if hFuncDesc != 0:
    hFunc = SAP.RfcCreateFunction(hFuncDesc, RfcErrInf)
    if hFunc != 0:

      hTable = c_void_p(0)

 

      #-Writes the report into the PROGRAM table------------------------
      if SAP.RfcGetTable(hFunc, "PROGRAM", hTable, RfcErrInf) == RFC_OK:
        for i in range(0, len(ABAP)):
          hRow = SAP.RfcAppendNewRow(hTable, RfcErrInf)
          rc = SAP.RfcSetChars(hRow, "LINE", ABAP[i], len(ABAP[i]), \
            RfcErrInf)

 

        if SAP.RfcInvoke(hRFC, hFunc, RfcErrInf) == RFC_OK:
          #-Gets the result from the WRITES table-----------------------
          if SAP.RfcGetTable(hFunc, "WRITES", hTable, RfcErrInf) == RFC_OK:
            RowCount = c_ulong(0)
            rc = SAP.RfcGetRowCount(hTable, RowCount, RfcErrInf)
            rc = SAP.RfcMoveToFirstRow(hTable, RfcErrInf)
            for i in range(0, RowCount.value):
              hRow = SAP.RfcGetCurrentRow(hTable, RfcErrInf)
              rc = SAP.RfcGetChars(hRow, "ZEILE", charBuffer, 256, \
                RfcErrInf)
              Result = Result + charBuffer.value
              if i < RowCount.value:
                rc = SAP.RfcMoveToNextRow(hTable, RfcErrInf)

 

            #-Shows the result------------------------------------------
            print(Result)

 

      rc = SAP.RfcDestroyFunction(hFunc, RfcErrInf)

 

  rc = SAP.RfcCloseConnection(hRFC, RfcErrInf)

 

else:
  print(RfcErrInf.key)
  print(RfcErrInf.message)

 

del SAP

 

#-End-------------------------------------------------------------------

 

As you can see, it is no problem to define and execute an ABAP program inside Python.

 

Enjoy it.

 

Cheers

Stefan

 

 

P.S. Here the file sapnwrfc.py


#-Begin-----------------------------------------------------------------

 

 

#-Packages--------------------------------------------------------------
from ctypes import *

 


#-Structures------------------------------------------------------------
class RFC_ERROR_INFO(Structure):
    _fields_ = [("code", c_long),
                ("group", c_long),
                ("key", c_wchar * 128),
                ("message", c_wchar * 512),
                ("abapMsgClass", c_wchar * 21),
                ("abapMsgType", c_wchar * 2),
                ("abapMsgNumber", c_wchar * 4),
                ("abapMsgV1", c_wchar * 51),
                ("abapMsgV2", c_wchar * 51),
                ("abapMsgV3", c_wchar * 51),
                ("abapMsgV4", c_wchar * 51)]

 

class RFC_CONNECTION_PARAMETER(Structure):
    _fields_ = [("name", c_wchar_p),
                ("value", c_wchar_p)]

 


#-Constants-------------------------------------------------------------

 

#-RFC_RC - RFC return codes---------------------------------------------
RFC_OK = 0
RFC_COMMUNICATION_FAILURE = 1
RFC_LOGON_FAILURE = 2
RFC_ABAP_RUNTIME_FAILURE = 3
RFC_ABAP_MESSAGE = 4
RFC_ABAP_EXCEPTION = 5
RFC_CLOSED = 6
RFC_CANCELED = 7
RFC_TIMEOUT = 8
RFC_MEMORY_INSUFFICIENT = 9
RFC_VERSION_MISMATCH = 10
RFC_INVALID_PROTOCOL = 11
RFC_SERIALIZATION_FAILURE = 12
RFC_INVALID_HANDLE = 13
RFC_RETRY = 14
RFC_EXTERNAL_FAILURE = 15
RFC_EXECUTED = 16
RFC_NOT_FOUND = 17
RFC_NOT_SUPPORTED = 18
RFC_ILLEGAL_STATE = 19
RFC_INVALID_PARAMETER = 20
RFC_CODEPAGE_CONVERSION_FAILURE = 21
RFC_CONVERSION_FAILURE = 22
RFC_BUFFER_TOO_SMALL = 23
RFC_TABLE_MOVE_BOF = 24
RFC_TABLE_MOVE_EOF = 25
RFC_START_SAPGUI_FAILURE = 26
RFC_ABAP_CLASS_EXCEPTION = 27
RFC_UNKNOWN_ERROR = 28
RFC_AUTHORIZATION_FAILURE = 29

 

#-RFCTYPE - RFC data types----------------------------------------------
RFCTYPE_CHAR = 0
RFCTYPE_DATE = 1
RFCTYPE_BCD = 2
RFCTYPE_TIME = 3
RFCTYPE_BYTE = 4
RFCTYPE_TABLE = 5
RFCTYPE_NUM = 6
RFCTYPE_FLOAT = 7
RFCTYPE_INT = 8
RFCTYPE_INT2 = 9
RFCTYPE_INT1 = 10
RFCTYPE_NULL = 14
RFCTYPE_ABAPOBJECT = 16
RFCTYPE_STRUCTURE = 17
RFCTYPE_DECF16 = 23
RFCTYPE_DECF34 = 24
RFCTYPE_XMLDATA = 28
RFCTYPE_STRING = 29
RFCTYPE_XSTRING = 30
RFCTYPE_BOX = 31
RFCTYPE_GENERIC_BOX = 32

 

#-RFC_UNIT_STATE - Processing status of a background unit---------------
RFC_UNIT_NOT_FOUND = 0
RFC_UNIT_IN_PROCESS = 1
RFC_UNIT_COMMITTED = 2
RFC_UNIT_ROLLED_BACK = 3
RFC_UNIT_CONFIRMED = 4

 

#-RFC_CALL_TYPE - Type of an incoming function call---------------------
RFC_SYNCHRONOUS = 0
RFC_TRANSACTIONAL = 1
RFC_QUEUED = 2
RFC_BACKGROUND_UNIT = 3

 

#-RFC_DIRECTION - Direction of a function module parameter--------------
RFC_IMPORT = 1
RFC_EXPORT = 2
RFC_CHANGING = RFC_IMPORT + RFC_EXPORT
RFC_TABLES = 4 + RFC_CHANGING

 

#-RFC_CLASS_ATTRIBUTE_TYPE - Type of an ABAP object attribute-----------
RFC_CLASS_ATTRIBUTE_INSTANCE = 0
RFC_CLASS_ATTRIBUTE_CLASS = 1
RFC_CLASS_ATTRIBUTE_CONSTANT = 2

 

#-RFC_METADATA_OBJ_TYPE - Ingroup repository----------------------------
RFC_METADATA_FUNCTION = 0
RFC_METADATA_TYPE = 1
RFC_METADATA_CLASS = 2


#-Variables-------------------------------------------------------------
ErrInf = RFC_ERROR_INFO; RfcErrInf = ErrInf()
ConnParams = RFC_CONNECTION_PARAMETER * 5; RfcConnParams = ConnParams()


#-Library---------------------------------------------------------------
SAPNWRFC = "sapnwrfc.dll"
SAP = windll.LoadLibrary(SAPNWRFC)

 

#-Prototypes------------------------------------------------------------
SAP.RfcAppendNewRow.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcAppendNewRow.restype = c_void_p

 

SAP.RfcCloseConnection.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcCloseConnection.restype = c_ulong

 

SAP.RfcCreateFunction.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcCreateFunction.restype = c_void_p

 

SAP.RfcDestroyFunction.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcDestroyFunction.restype = c_ulong

 

SAP.RfcGetChars.argtypes = [c_void_p, c_wchar_p, c_void_p, c_ulong, \
  POINTER(ErrInf)]
SAP.RfcGetChars.restype = c_ulong

 

SAP.RfcGetCurrentRow.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcGetCurrentRow.restype = c_void_p

 

SAP.RfcGetFunctionDesc.argtypes = [c_void_p, c_wchar_p, POINTER(ErrInf)]
SAP.RfcGetFunctionDesc.restype = c_void_p

 

SAP.RfcGetRowCount.argtypes = [c_void_p, POINTER(c_ulong), \
  POINTER(ErrInf)]
SAP.RfcGetRowCount.restype = c_ulong

 

SAP.RfcGetStructure.argtypes = [c_void_p, c_wchar_p, \
  POINTER(c_void_p), POINTER(ErrInf)]
SAP.RfcGetStructure.restype = c_ulong

 

SAP.RfcGetTable.argtypes = [c_void_p, c_wchar_p, POINTER(c_void_p), \
  POINTER(ErrInf)]
SAP.RfcGetTable.restype = c_ulong

 

SAP.RfcGetVersion.argtypes = [POINTER(c_ulong), POINTER(c_ulong), \
  POINTER(c_ulong)]
SAP.RfcGetVersion.restype = c_wchar_p

 

SAP.RfcInvoke.argtypes = [c_void_p, c_void_p, POINTER(ErrInf)]
SAP.RfcInvoke.restype = c_ulong

 

SAP.RfcMoveToFirstRow.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcMoveToFirstRow.restype = c_ulong

 

SAP.RfcMoveToNextRow.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcMoveToNextRow.restype = c_ulong

 

SAP.RfcOpenConnection.argtypes = [POINTER(ConnParams), c_ulong, \
  POINTER(ErrInf)]
SAP.RfcOpenConnection.restype = c_void_p

 

SAP.RfcPing.argtypes = [c_void_p, POINTER(ErrInf)]
SAP.RfcPing.restype = c_ulong

 

SAP.RfcSetChars.argtypes = [c_void_p, c_wchar_p, c_wchar_p, c_ulong, \
  POINTER(ErrInf)]
SAP.RfcSetChars.restype = c_ulong

 

#-End-------------------------------------------------------------------


How to use actual SAP NetWeaver RFC Library with Python - Read Table

$
0
0

Hello community,

 

I presented until now in the series "How to use actual SAPNetWeaver RFC Library with Pyhton" :

 

Here now an example how to read a table with the function module (FM) RFC_READ_TABLE. You need the file sapnwrfc.py from here - look at the end of the posting.

After the connection we get the function description of the FM, in our case RFC_READ_TABLE. We set the arguments QUERY_TABLE, in our case USR01, and the DELIMITER. We invoke the FM and print the result line by line. The result is in the DATA table, in the field WA.

 

# -*- coding: iso-8859-15 -*-

#-Begin-----------------------------------------------------------------

 

#-Include---------------------------------------------------------------

FileName = "sapnwrfc.py"

exec(compile(open(FileName).read(), FileName, "exec"))

 

#-Main------------------------------------------------------------------

 

#-Connection parameters-------------------------------------------------

RfcConnParams[0].name = "ASHOST"; RfcConnParams[0].value = "ABAP"

RfcConnParams[1].name = "SYSNR" ; RfcConnParams[1].value = "00"

RfcConnParams[2].name = "CLIENT"; RfcConnParams[2].value = "001"

RfcConnParams[3].name = "USER"  ; RfcConnParams[3].value = "BCUSER"

RfcConnParams[4].name = "PASSWD"; RfcConnParams[4].value = "minisap"

 

TableName = "USR01"

 

hRFC = SAP.RfcOpenConnection(RfcConnParams, 5, RfcErrInf)

if hRFC != None:

 

  charBuffer = create_unicode_buffer(512 + 1)

 

  hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "RFC_READ_TABLE", RfcErrInf)

  if hFuncDesc != 0:

    hFunc = SAP.RfcCreateFunction(hFuncDesc, RfcErrInf)

    if hFunc != 0:

 

      rc = SAP.RfcSetChars(hFunc, "QUERY_TABLE", TableName, \

        len(TableName), RfcErrInf)

      rc = SAP.RfcSetChars(hFunc, "DELIMITER", "~", 1, RfcErrInf)

 

      if SAP.RfcInvoke(hRFC, hFunc, RfcErrInf) == RFC_OK:

 

        hTable = c_void_p(0)

        if SAP.RfcGetTable(hFunc, "DATA", hTable, RfcErrInf) == RFC_OK:

 

          RowCount = c_ulong(0)

          rc = SAP.RfcGetRowCount(hTable, RowCount, RfcErrInf)

          rc = SAP.RfcMoveToFirstRow(hTable, RfcErrInf)

          for i in range(0, RowCount.value):

            hRow = SAP.RfcGetCurrentRow(hTable, RfcErrInf)

            rc = SAP.RfcGetChars(hRow, "WA", charBuffer, 512, RfcErrInf)

            print(charBuffer.value)

            if i < RowCount.value:

              rc = SAP.RfcMoveToNextRow(hTable, RfcErrInf)

 

      rc = SAP.RfcDestroyFunction(hFunc, RfcErrInf)

 

  rc = SAP.RfcCloseConnection(hRFC, RfcErrInf)

 

else:

  print(RfcErrInf.key)

  print(RfcErrInf.message)

 

del SAP

 

#-End-------------------------------------------------------------------

 

Cheers

Stefan

saprfc.dll for php 5.4 or upper version

$
0
0

Hai All,

 

Purpose for interfacing SAP in PHP, Is there any saprfc.dll build for xamp version 1.7.3 or upper, or PHP 5.4 or upper,

Now, I already use saprfc.dll what compatible for PHP 5.2 only..

 

Thank for answer.

 

arif diyanto

SAP Database

$
0
0

Hi experts, How to make enter to SAP database and with querys SQL make reports? Is possible? How to make integration to softwares, of the reports, for example Ireports, CrystalReports? Tanks

Check to determine if field is modifiable/editable?

$
0
0

On the offchance that anyone knows this, i'm having a bit of an issue figuring out how to make my script determine if an SAP field is editable or if it is locked for editing.  The fieldname is constant with a coordinate value (which i'm accounting for in the script)

 

session.findById("wnd[0]/usr/tblSAPLCOMKTCTRL_0120/ctxtRESBD-CHARG[14,0]")

 

But either i've forgotten how to make this thing determine editable non-editable... as shown below, item 0035 can be edited.  Item 0010 phantom component is locked.

Capture.JPG

How to use actual SAP NetWeaver RFC Library with Python - Python Server Application

$
0
0

Hello community,

 

I presented until now in the series "How to use actual SAPNetWeaver RFC Library with Pyhton" :

 

Here now an example how to use Python as server application from ABAP.

 

We start with the transaction code SM59 to configure the RFC destination of the Python server application.

001.JPG

Here the Python source:

 

# -*- coding: iso-8859-15 -*-

#-Begin-----------------------------------------------------------------

 

#-Packages--------------------------------------------------------------

from threading import Thread

import time

 

#-Include---------------------------------------------------------------

FileName = "sapnwrfc.py"

exec(compile(open(FileName).read(), FileName, "exec"))

 

#-Asynchronous function-------------------------------------------------

def SetQuit():

  global Quit

  windll.user32.MessageBoxW(None, "Stop Python server", "", 0)

  Quit = True

 

#-ABAP CallBack---------------------------------------------------------

def ABAPCall(rfcHandle, funcHandle, RfcErrInf):

  windll.user32.MessageBoxW(None, "ABAP calling", "", 0)

  return RFC_OK

 

#-Main------------------------------------------------------------------

Quit = False

t = Thread(target=SetQuit); t.start()

 

#-Connection parameters-------------------------------------------------

RfcSConParams[0].name = "PROGRAM_ID"; RfcSConParams[0].value = "PYTHONSERVER"

RfcSConParams[1].name = "GWHOST"    ; RfcSConParams[1].value = "ABAP"

RfcSConParams[2].name = "GWSERV"    ; RfcSConParams[2].value = "sapgw00"

 

ABAPFunc = WINFUNCTYPE(c_ulong, c_void_p, c_void_p, POINTER(ErrInf))

hDesc = SAP.RfcCreateFunctionDesc("ABAPCall", RfcErrInf)

if hDesc != None:

  if SAP.RfcInstallServerFunction("NSP", hDesc, ABAPFunc(ABAPCall), \

    RfcErrInf) == RFC_OK:

 

    hCon = SAP.RfcRegisterServer(RfcSConParams, 3, RfcErrInf)

    if hCon != None:

      rc = RFC_OK

      while (rc == RFC_OK, rc == RFC_RETRY):

        rc = SAP.RfcListenAndDispatch(hCon, 1, RfcErrInf)

        time.sleep(0.250)

        if Quit == True:

          break

    else:

      print(RfcErrInf.key); print(RfcErrInf.message)

 

  else:

    print(RfcErrInf.key); print(RfcErrInf.message)

 

  rc = SAP.RfcDestroyFunctionDesc(hDesc, RfcErrInf)

 

else:

  print(RfcErrInf.key); print(RfcErrInf.message)

 

del SAP

 

#-End-------------------------------------------------------------------

 

We define at first an asynchonous thread, to set a global variable to break the execution of the server, when we no longer need it. Then we define the callback function, which can be called from ABAP - in our case only a simple message box. We create an empty function description with RfcCreateFunctionDesc and install, with this description, the callback function on the SAP system with RfcInstallServerFunction. Now we register the server connection at an SAP gateway via RFCRegisterServer and listen for incoming RFC calls with RfcListenAndDispatch. Very simple, isn't it?

 

Now we can use the Python function ABAPCall from ABAP like this:

 

"-Begin-----------------------------------------------------------------

  Program ZTEST.


    Call Function 'ABAPCall' Destination 'PYTHONSERVER'.

 

"-End-------------------------------------------------------------------

 

And this is the result:

002.JPG

As you can see, it is very easy to use Python as SAP server application.

 

Cheers

Stefan

 

P.S. Here  the updated include file sapnwrfc.py:

 

#-Begin-----------------------------------------------------------------

 

#-Packages--------------------------------------------------------------

from ctypes import *

import platform, os

 

#-Structures------------------------------------------------------------

class RFC_ERROR_INFO(Structure):

    _fields_ = [("code", c_long),

                ("group", c_long),

                ("key", c_wchar * 128),

                ("message", c_wchar * 512),

                ("abapMsgClass", c_wchar * 21),

                ("abapMsgType", c_wchar * 2),

                ("abapMsgNumber", c_wchar * 4),

                ("abapMsgV1", c_wchar * 51),

                ("abapMsgV2", c_wchar * 51),

                ("abapMsgV3", c_wchar * 51),

                ("abapMsgV4", c_wchar * 51)]

 

class RFC_CONNECTION_PARAMETER(Structure):

    _fields_ = [("name", c_wchar_p),

                ("value", c_wchar_p)]

 

 

#-Constants-------------------------------------------------------------

 

#-RFC_RC - RFC return codes---------------------------------------------

RFC_OK = 0

RFC_COMMUNICATION_FAILURE = 1

RFC_LOGON_FAILURE = 2

RFC_ABAP_RUNTIME_FAILURE = 3

RFC_ABAP_MESSAGE = 4

RFC_ABAP_EXCEPTION = 5

RFC_CLOSED = 6

RFC_CANCELED = 7

RFC_TIMEOUT = 8

RFC_MEMORY_INSUFFICIENT = 9

RFC_VERSION_MISMATCH = 10

RFC_INVALID_PROTOCOL = 11

RFC_SERIALIZATION_FAILURE = 12

RFC_INVALID_HANDLE = 13

RFC_RETRY = 14

RFC_EXTERNAL_FAILURE = 15

RFC_EXECUTED = 16

RFC_NOT_FOUND = 17

RFC_NOT_SUPPORTED = 18

RFC_ILLEGAL_STATE = 19

RFC_INVALID_PARAMETER = 20

RFC_CODEPAGE_CONVERSION_FAILURE = 21

RFC_CONVERSION_FAILURE = 22

RFC_BUFFER_TOO_SMALL = 23

RFC_TABLE_MOVE_BOF = 24

RFC_TABLE_MOVE_EOF = 25

RFC_START_SAPGUI_FAILURE = 26

RFC_ABAP_CLASS_EXCEPTION = 27

RFC_UNKNOWN_ERROR = 28

RFC_AUTHORIZATION_FAILURE = 29

 

#-RFCTYPE - RFC data types----------------------------------------------

RFCTYPE_CHAR = 0

RFCTYPE_DATE = 1

RFCTYPE_BCD = 2

RFCTYPE_TIME = 3

RFCTYPE_BYTE = 4

RFCTYPE_TABLE = 5

RFCTYPE_NUM = 6

RFCTYPE_FLOAT = 7

RFCTYPE_INT = 8

RFCTYPE_INT2 = 9

RFCTYPE_INT1 = 10

RFCTYPE_NULL = 14

RFCTYPE_ABAPOBJECT = 16

RFCTYPE_STRUCTURE = 17

RFCTYPE_DECF16 = 23

RFCTYPE_DECF34 = 24

RFCTYPE_XMLDATA = 28

RFCTYPE_STRING = 29

RFCTYPE_XSTRING = 30

RFCTYPE_BOX = 31

RFCTYPE_GENERIC_BOX = 32

 

#-RFC_UNIT_STATE - Processing status of a background unit---------------

RFC_UNIT_NOT_FOUND = 0

RFC_UNIT_IN_PROCESS = 1

RFC_UNIT_COMMITTED = 2

RFC_UNIT_ROLLED_BACK = 3

RFC_UNIT_CONFIRMED = 4

 

#-RFC_CALL_TYPE - Type of an incoming function call---------------------

RFC_SYNCHRONOUS = 0

RFC_TRANSACTIONAL = 1

RFC_QUEUED = 2

RFC_BACKGROUND_UNIT = 3

 

#-RFC_DIRECTION - Direction of a function module parameter--------------

RFC_IMPORT = 1

RFC_EXPORT = 2

RFC_CHANGING = RFC_IMPORT + RFC_EXPORT

RFC_TABLES = 4 + RFC_CHANGING

 

#-RFC_CLASS_ATTRIBUTE_TYPE - Type of an ABAP object attribute-----------

RFC_CLASS_ATTRIBUTE_INSTANCE = 0

RFC_CLASS_ATTRIBUTE_CLASS = 1

RFC_CLASS_ATTRIBUTE_CONSTANT = 2

 

#-RFC_METADATA_OBJ_TYPE - Ingroup repository----------------------------

RFC_METADATA_FUNCTION = 0

RFC_METADATA_TYPE = 1

RFC_METADATA_CLASS = 2

 

 

#-Variables-------------------------------------------------------------

ErrInf = RFC_ERROR_INFO; RfcErrInf = ErrInf()

ConnParams = RFC_CONNECTION_PARAMETER * 5; RfcConnParams = ConnParams()

SConParams = RFC_CONNECTION_PARAMETER * 3; RfcSConParams = SConParams()

 

 

#-Library---------------------------------------------------------------

if str(platform.architecture()[0]) == "32bit":

  os.environ['PATH'] += ";C:\\SAPRFCSDK\\32bit"

  SAPNWRFC = "C:\\SAPRFCSDK\\32bit\\sapnwrfc.dll"

elif str(platform.architecture()[0]) == "64bit":

  os.environ['PATH'] += ";C:\\SAPRFCSDK\\64bit"

  SAPNWRFC = "C:\\SAPRFCSDK\\64bit\\sapnwrfc.dll"

SAP = windll.LoadLibrary(SAPNWRFC)

 

 

#-Prototypes------------------------------------------------------------

SAP.RfcAppendNewRow.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcAppendNewRow.restype = c_void_p

 

SAP.RfcCloseConnection.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcCloseConnection.restype = c_ulong

 

SAP.RfcCreateFunction.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcCreateFunction.restype = c_void_p

 

SAP.RfcCreateFunctionDesc.argtypes = [c_wchar_p, POINTER(ErrInf)]

SAP.RfcCreateFunctionDesc.restype = c_void_p

 

SAP.RfcDestroyFunction.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcDestroyFunction.restype = c_ulong

 

SAP.RfcDestroyFunctionDesc.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcDestroyFunctionDesc.restype = c_ulong

 

SAP.RfcGetChars.argtypes = [c_void_p, c_wchar_p, c_void_p, c_ulong, \

  POINTER(ErrInf)]

SAP.RfcGetChars.restype = c_ulong

 

SAP.RfcGetCurrentRow.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcGetCurrentRow.restype = c_void_p

 

SAP.RfcGetFunctionDesc.argtypes = [c_void_p, c_wchar_p, POINTER(ErrInf)]

SAP.RfcGetFunctionDesc.restype = c_void_p

 

SAP.RfcGetRowCount.argtypes = [c_void_p, POINTER(c_ulong), \

  POINTER(ErrInf)]

SAP.RfcGetRowCount.restype = c_ulong

 

SAP.RfcGetStructure.argtypes = [c_void_p, c_wchar_p, \

  POINTER(c_void_p), POINTER(ErrInf)]

SAP.RfcGetStructure.restype = c_ulong

 

SAP.RfcGetTable.argtypes = [c_void_p, c_wchar_p, POINTER(c_void_p), \

  POINTER(ErrInf)]

SAP.RfcGetTable.restype = c_ulong

 

SAP.RfcGetVersion.argtypes = [POINTER(c_ulong), POINTER(c_ulong), \

  POINTER(c_ulong)]

SAP.RfcGetVersion.restype = c_wchar_p

 

SAP.RfcInstallServerFunction.argtypes = [c_wchar_p, c_void_p, \

  c_void_p, POINTER(ErrInf)]

SAP.RfcInstallServerFunction.restype = c_ulong

 

SAP.RfcInvoke.argtypes = [c_void_p, c_void_p, POINTER(ErrInf)]

SAP.RfcInvoke.restype = c_ulong

 

SAP.RfcListenAndDispatch.argtypes = [c_void_p, c_ulong, POINTER(ErrInf)]

SAP.RfcListenAndDispatch.restype = c_ulong

 

SAP.RfcMoveToFirstRow.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcMoveToFirstRow.restype = c_ulong

 

SAP.RfcMoveToNextRow.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcMoveToNextRow.restype = c_ulong

 

SAP.RfcOpenConnection.argtypes = [POINTER(ConnParams), c_ulong, \

  POINTER(ErrInf)]

SAP.RfcOpenConnection.restype = c_void_p

 

SAP.RfcPing.argtypes = [c_void_p, POINTER(ErrInf)]

SAP.RfcPing.restype = c_ulong

 

SAP.RfcRegisterServer.argtypes = [POINTER(SConParams), c_ulong, \

  POINTER(ErrInf)]

SAP.RfcRegisterServer.restype = c_void_p

 

SAP.RfcSetChars.argtypes = [c_void_p, c_wchar_p, c_wchar_p, c_ulong, \

  POINTER(ErrInf)]

SAP.RfcSetChars.restype = c_ulong

 

#-End-------------------------------------------------------------------

Interactive and dynamic Excel VBA template - SAP GUI Scripting -

$
0
0

Introduction:

 

SAP GUI Scripting can be used for many small and intermediate batches for mass maintenance tasks (P-/Q- and D-Systems) and quality testing (Q-Systems) in SAP.

To reduce development workload or modify a lot of code for different SAP GUI recordings I saw a need for having an Excel VBA template which can cover a lot of requirements.

 

Features:

 

  • Easy to use (One-Button-Solution).
  • Excel functions and options can be used for data preparation and consolidation in front of starting update procedure.
  • During initialization all existing and non-busy SAP sessions got displayed (UI-Listbox). So we are able to select a specific session for Excel VBA adoption.
  • Data from SAP can easily imported into Excel worksheet (Data from ALV-list, fields, result list, status messages, error messages,… and so on).
  • Only SAP GUI Scripting recording code need to integrate into VBA module ‘SAP_1_PROCESS’.
  • More columns as data source or destination for field data can be added. Last two columns are reserved for procedure usage. This is achieved by using a data-array which got ‘Redim’ during process according to used rows and columns.
  • Log-function is integrated (for SAP messages like statusbar Messages or free-text).

 

Prepare Excel VBA template:

  1. Step: Create folder on your desktop (or somewhere else) => folder name is up to you.
  2. Step: Store below text-files into this folder: Please be aware that text-file 'Modules_All.txt' need to split into four text-files named 'SAP_1_Process', 'SAP_2_Functions'. SAP_3_Public_Subs' and 'Module1'! Start and end of module specific coding is marked and must removed before saving of single text-file. First line in this files must be Attribute VB_Name = "SAP_1_Process", Attribute VB_Name = "SAP_2_Functions" and Attribute VB_Name = "SAP_3_Public_Subs". As I can´t upload more than three files you Need to split Modules_All.txt on your own and save files in folder.
    1. SAP_1_Process.txt
    2. SAP_2_Functions.txt
    3. SAP_3_Public_Subs.txt
    4. Userform1_frm.txt
    5. Userform1_frx.txt
    6. Module1.txt
  3. Step: Create a new Excel workbook and store this in same folder as text-files. You can choice every name you want. My suggestion is ‘Prepare_WB.xlsx’.
  4. Step: Now go into VBE of Excel ( ALT + F11) => insert Module => open text-file ‘Module1.txt’ => Select all and copy => paste into new module from Excel workbook.
  5. Step: Execute macro ‘prepare_worksheet’ (Reference to sapfewse.oxs will done utomatically. This require Folder-structure ENVIRON("PROGRAMFILES") & "\SAP\FRONTEND\SAPgui\sapfewse.oxs"). If you have an different Destination please add manual.
  6. Step: Remove ‘Module1’ from macro-enabled workbook and save.
  7. Done

 

Textfile_before_Split.png

Textfile_after_Split.png

Folder_Prepare.png

After_Prepare.png

VBE_Reference.png

VBA_sapfewse.ocx.png

 

Usage of Excel VBA template (MM03_VBA_SAP_SCRIPTING_V1.xlsm):

 

This Excel template have for demonstration purposes SAP GUI Scripting integrated for getting MM03 data from ‘stor. loc. stck’-tab => ‘Qty. Unrestricted’ + “UoM’ + ‘Material description’ data.

 

  1. Step: Fillin ‘Materialnumber’ + ‘Company Code’ + ‘Storage location’ combination used in your system. As error handling is integrated for ‘Company Code’ + ‘Storage location’ combination you can test this as well.
  2. Step: Press button ‘Run macro ‘SAP_PROCESS’’
  3. Step: All open and Scripting-enabled SAP sessions got displayed in a Userform-Listbox
  4. Step: Select one session and press ‘Enter’ or Commandbutton
  5. Done: Script got executed and you will get data into Excel according to your input data combination (Materialnumber/CoCode/Storage location).

 

WS_SAP_PROCESS.png

SAP_SESSIONS.png

 

Important data structure information:

All data from Excel worksheet ‘SAP_PROCESS’ got stored into data-array ‘arr_SAP_Data’. This Array is defined with same number range as our used worksheet range. Starting from row ‘2’ up to last used row and all used columns (remember that last two columns are reserved for procedure process).

arr_SAP_Data(lngCounter, (lng_Col + 0))

 

=> lngCounter is current executed row in worksheet. (lng_col +0) define column ‘1’

=> (lng_col +1) is second column

=> and so on.

 

When you add or delete columns please save workbook immediately.

Conclusion:

 

Feel free to use this template for your requirements by modify coding in ‘SAP_1_Process’-module. But be aware that I am not responsible for any issues, inconsistencies or other incidents which can cause by using this template. Feel free to ask if you Need any additional information. But do not expect any support for your purposes and requirements. Hope this will give you some lights how SAP GUI Scripting can make your daily tasks much smoother.


Help with Scripting: Release strategy data export from ME23N to excel from list of PO #'s

$
0
0

Hello,

 

New to SAP here and want to make a script to pull data. Never made an SAP script before

 

I have LOTS of emails (50,000+ ) That contain PO #'s.In Outlook i created a VBA macro(With help from online as this was my first vba) to go through the selected emails of my choice and copy that PO number into an excel spreadsheet.

 

 

I am looking up the PO's in SAP SSO ME23N to see if they have a green check mark in the release strategy status box. Is there a way i can have SAP Grab the PO's off my spreadsheet, Look them up to see if they have the green check mark, and put that data in Column B of my excel spreadsheet?

 

I can do the sorting i need from there

 

 

All help is greatly appreciated!

Error with variables

$
0
0

Hi exeperts. The SAP does not accept, use variables in their addresses? For example:

 

In the line :

session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[i-1,83]").Selected = True

 

Thank's

 

for i=1 to 15
If Cells(x, 4) = i Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[i-1,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
Next





rue

Help!!! SAP report extraction through pdf(Print Option) using Macro

$
0
0

Hi,

 

Please someone could help me in extracting one of SAP report using Print option(spooling) using Macro. I have recorded a macro for print, giving the destination as "LOCL" and I get a popup "Save PDF File As" dialog box which does not run in Macro. The Macro runs only upto LOCL printer selection. I want a Macro to run even when the prompt for "Save PDF File As" dialog box with the directory and file name to be picked from excel and saves automatically in the directory choosen... Please someone could help me with the code for it?

 

TIA

Merci

Error in the loop

$
0
0

I made the code below:

 

 

For x = 4 To 5000
If Cells(x, 2) = "" Then Exit For
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nmb22"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRM07M-RSNUM").Text = Cells(x, 2)
session.findById("wnd[0]/usr/ctxtRM07M-RSNUM").caretPosition = 0
session.findById("wnd[0]").sendVKey 0
'-----------ITENS-------------------------
If Cells(x, 4) = 1 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[0,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 2 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[1,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 3 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[2,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 4 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[3,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 5 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[4,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 6 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[5,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 7 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[6,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
If Cells(x, 4) = 8 Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[7,83]").Selected = True
session.findById("wnd[0]/tbar[0]/btn[11]").press
Cells(x, 3) = session.findById("wnd[0]/sbar").Text
End If
Next

This code is OK.

 

But i made the loop. because the  code is very big:

 

For x = 4 To 5000
If Cells(x, 2) = "" Then Exit For
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nmb22"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRM07M-RSNUM").Text = Cells(x, 2)
session.findById("wnd[0]/usr/ctxtRM07M-RSNUM").caretPosition = 0
session.findById("wnd[0]").sendVKey 0
'-----------ITENS-------------------------
For i = 1 To 15
If Cells(x, 4) = i Then
session.findById("wnd[0]/usr/sub:SAPMM07R:0521/chkRESB-XLOEK[" & (i - 1) & ",83]").Selected = True 'marca a linha em aberto.
session.findById("wnd[0]/tbar[0]/btn[11]").press 'salvar
Cells(x, 3) = session.findById("wnd[0]/sbar").Text 'pega msg gerada
End If
Next
Next

But the code with the loop is not OK.  Whats the error?

 

Tank's

Copy-Paste dates from Excel in SAP script

$
0
0

Hello,

 

I did a script in SAP. It goes in an Excel file to copy delivery dates and goes and paste them in a purchase order.

The date format in Excel is the same one as in SAP (YYYY/MM/DD), except that the script pastes the date format shown in the toolbar only (YYYY-MM-DD). Which is different and blocks the script.

date.gif

I know you can change the regional settings of the computer, but to get YYYY/MM/DD I need to put it to English South Africa which is not good because it changes other settings. I can also change the date format in SAP to make it match to my Excel file, but this is not good either because the people using this script will have a date format in SAP different then the other users and will cause confusion.

 

Is there a way for the SAP script to copy-paste the date format in the cell 2014/01/16 and not the 2014-01-16?

 

 

Patricia

How to make SAP Script/Macro run in background like xl macros

$
0
0

Hi,

 

I have a recorded sap script to run, but I can see all  the steps visible in the screen. Is there a  solution in SAP to set displayalerts or screenupdate as false like excel. I do not want the viewers to see the macro running in all steps. I tried iconify, but it works only for main screen, the child screen are still visible. Please help.

 

Thanks

Mercy

How to connect Access VBA with a customer specific function module using RFC

$
0
0

Hello,

 

I try to fetch some data from our SAP ERP system by using a customer specific function module.

The connection via RFC is working. Unfortunately, after trying to add the SAP function module to the connection, the result is still nothing.

 

I have a VBA function for the connection. The return value of this function is the working connectin to SAP system.

 

Private Function sapConnect() As Object
'---------------------------------------------------------------------------------------
' Procedure : sapConnect
' Author    : Steffen Retz
' Date      : 22.11.2013
' Purpose   :
'---------------------------------------------------------------------------------------
'
Dim sapConnection   As Object
Dim sapFunction     As Object
Dim RetVal          As Variant
Dim ME5             As Variant
Dim strSAP_System   As String   On Error GoTo sapConnect_Error
'Set sapConnect = False
Set sapFunction = CreateObject("SAP.Functions")
Set sapConnection = sapFunction.Connection
With sapConnection    .ApplicationServer = "xx.xxx.xx.xx"    .SystemNumber = xxx    .System = "xxx"    .client = "xxx"    .Language = "EN"    .User = m_strcUserName 'InputBox("Please insert your SAP user name", "SAP Connection: User")    '.Password = InputBox("Please insert you SAP password", "SAP Connection: Password")    RetVal = SysCmd(acSysCmdSetStatus, "Connecting to " & strSAP_System & " . . . ")           If .logon(0, True) <> True Then        If .logon(0, False) <> True Then            'No connection -> Error            .LastError             Exit Function        End If               Set sapConnect = sapFunction    End If   
End With
sapConnect_Exit:    On Error Resume Next    Exit Function   
sapConnect_Error:    Err.Number = vbObjectError + 1    Err.Source = m_strcClassName    Err.Description = "Error" & " <<>> " & Err.Description    LogError Err, Critical, "sapConnect"    GoTo sapConnect_Exit      On Error GoTo 0
End Function

 

The other function is using the returning connection to retrieve the data from the SAP system.

After adding the function module to the connection, I recognized that the object MyFunc is still empty.

 

Set MyFunc = R3.Add("Z_ZZMHP_HR_SAP_NOTES_READ")

 

I also tried this with RFC_READ_TABLE and BAPI_USER_GETLIST. Both functions are working.

 

 

Private Function RFC_SAP_NOTES_READ(sapConnection As Object, arrSAPNotes As Variant) As Boolean
'---------------------------------------------------------------------------------------
' Procedure : RFC_SAP_NOTES_READ
' Author    : Steffen Retz
' Date      : 03.12.2013
' Purpose   : FM in SAP: Z_ZZMHP_HR_SAP_NOTES_READ
'---------------------------------------------------------------------------------------
'
Dim strTemp As String
Dim RetVal As Variant, nSecondsLeft As Long, nTotalSeconds As Long
Dim R3, MyFunc, App As Object
Dim j As Integer
' Define the objects to hold IMPORT parameters
Dim IT_SAP_NOTES_KEY As Object
' Define the objects to hold the EXPORT parameters
Dim ZZMHP_TT_HR_SAP_NOTES_ERRORMSG As Object
Dim ET_SAP_NOTES As Object
' Use to write out results
Dim ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow, iField, iLength As Integer   On Error GoTo RFC_SAP_NOTES_READ_Error
If sapConnection Is Nothing Then    Set R3 = sapConnect
Else    Set R3 = sapConnection
End If
'*****************************************************
'Call RFC function Z_ZZMHP_HR_SAP_NOTES_READ
'*****************************************************
Set MyFunc = R3.Add("Z_ZZMHP_HR_SAP_NOTES_READ")
'EXPORTS
Set IT_SAP_NOTES_KEY = MyFunc.exports("IT_SAP_NOTE_KEY")
IT_SAP_NOTES_KEY.Value = arrSAPNotes
'IMPORTS
Set ZZMHP_TT_HR_SAP_NOTES_ERRORMSG = MyFunc.imports("ZZMHP_TT_HR_SAP_NOTES_ERRORMSG")
Set ET_SAP_NOTES = MyFunc.imports("ET_SAP_NOTES")
RetVal = SysCmd(acSysCmdSetStatus, "Extracting " & j & " . . . ")
MyFunc.Call
' Result = MyFunc.Call
' If Result = True Then
'     Set DATA = MyFunc.Tables("DATA")
'     Set FIELDS = MyFunc.Tables("FIELDS")
'     Set OPTIONS = MyFunc.Tables("OPTIONS")
' Else
'     MsgBox MyFunc.EXCEPTION
'     R3.Connection.LOGOFF
'     Exit Function
' End If     
Close #2
RetVal = SysCmd(acSysCmdRemoveMeter)
RFC_SAP_NOTES_READ = True
RFC_SAP_NOTES_READ_Exit:    On Error Resume Next    Exit Function   
RFC_SAP_NOTES_READ_Error:    RFC_SAP_NOTES_READ = False    Err.Number = vbObjectError + 1    Err.Source = m_strcClassName    Err.Description = "Error" & " <<>> " & Err.Description    Debug.Print Err.Description    LogError Err, Critical, "RFC_READ_TABLE"    GoTo RFC_SAP_NOTES_READ_Exit      On Error GoTo 0
End Function

I can't find the error. Do I have to use a specific method for a customer specific fuction module?

Or is it not possible to use a customer specific function module?

 

Thanks for any help.

 

Best regards,

 

Steffen


LOGIN TO SAP SYSTEM from Ms Excell

$
0
0

Hello All,

 

I have one requriment, I have to login SAP system through Excell.

For login to MS Excell,is it  requried to SAP LOGON pad should be insatalled in SYSTEM.

 

I am using Below code to login.

 

Sub logon_to_sap()

Set ObjR3 = CreateObject("SAP.Functions")

    '--get this info from your logon pad..

           ObjR3.Connection.System = "CRM" 'System name like : DEV 3 letter'

           ObjR3.Connection.Client = "100" 'client number like 100'

           ObjR3.Connection.User = ""   'User ID to logon '

           ObjR3.Connection.Password = ""  'Password '

           ObjR3.Connection.Language = "EN" 'Language'

           ObjR3.Connection.ApplicationServer = "xx.xx.xx.xx 'Applicaiotn server name e.g. 10.x.x.x'

           ObjR3.Connection.SystemNumber = "00" 'Instance number'

        

        '--if no logon then exit\

           If ObjR3.Connection.logon(0, False) <> True Then

              WScript.Echo "Sap connection error - " & ObjR3.Connection.User & " - " & ObjR3.Connection.System

              WScript.Quit

           End If

        

End Sub

 

But I am getting below Error.

 

 

Error Group

 

RFC_ERROR_COMMUNICATION

 

Message

 

CMALLC : rc=20 > Connect from SAP gateway to RFC
server failed

 

Connect_PM  GWHOST='XX.XX.XX.XX , GWSERV=sapgw00,
SYSNR=00

 

LOCATION    SAP-Gateway on host

ERROR       partner
'XX.XX.XX.XX sapgw00' not reached

TIME         Sep
10:21:50 2014

RELEASE     721

COMPONENT   NI (network interface)

VERSION     40

RC        
-10

MODULE      nixxi.cpp

LINE        3286

DETAIL      NiPConnect2:
SYSTEM CALL connect

ERRNO       10060

ERRNO TEXT  WSAETIME

 

 

Thanks In advance.

 

Regards

RR Pradhan

CALL SAP WEB SERVICE FROM MS EXCEL 2010 using VBA

$
0
0

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING


*"     VALUE(PROCESS_TYPE) TYPE  CRMT_PROCESS_TYPE

*"     VALUE(SUCCESS) TYPE  CRMT_PROBABILITY OPTIONAL

*"  EXPORTING

*"     VALUE(MESSAGE) TYPE  CHAR255

*"     VALUE(OBJECT_ID) TYPE  CRMT_OBJECT_ID

 

Code of WEB SERVICE

<?xml
version="1.0" encoding="utf-8"
?> 
+<wsdl:definitions
targetNamespace
="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions"
-<wsdl:documentation>
Importing parameter for WEB Service

 

 

<n0:ZcrmOrderMaintainUday xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">

<Phase>Str</Phase>

<ProcessType>Stri</ProcessType>

</n0:ZcrmOrderMaintainUday>

Code IN VBA(EXCEL)

Private Sub CommandButton1_Click()

  Dim sURL As String

    Dim sEnv As String

    Dim xmlhtp As New MSXML2.XMLHTTP40

    Dim xmlDoc As New DOMDocument

    'sURL = "http://webservices.gama-system.com/exchangerates.asmx?op=CurrentConvertToEUR"]http://webservices.gama-system.com/exchangerates.asmx?op=CurrentConvertToEUR[/URL]"

       sURL = "http://ides.studynest.org:8023/sap/bc/srt/wsdl/sdef_ZWS_TEST_UDAY_WEB/wsdl11/ws_policy/document?sap-client=800"

    sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"

   

   sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"

    'sEnv = sEnv & "<soap:Envelope xmlns:xsi="""http://www.w3.org/2001/XMLSchema-instance"http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd="""http://www.w3.org/2001/XMLSchema"]http://www.w3.org/2001/XMLSchema[/URL]"" xmlns:soap=""[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/"">"

    sEnv = sEnv & "  <soap:Body>"

    sEnv = sEnv & "    <sdef_ZWS_TEST_UDAY_WEB xmlns=""http://ides.studynest.org/webservices" > ""

   sEnv = sEnv & " <DESC>Test Of Visit Reprot by Prasmi</DESC>"

    sEnv = sEnv & " <PROCESS_TYPE>LEAD</PROCESS_TYPE>"

    sEnv = sEnv & "    </sdef_ZWS_TEST_UDAY_WEB>"

    sEnv = sEnv & "  </soap:Body>"

    sEnv = sEnv & "</soap:Envelope>"

    

    With xmlhtp

        .Open "post", sURL, False

        .setRequestHeader "Host", "ides.studynest.org"

        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"

        .setRequestHeader "soapAction", "http://ides.studynest.org:8023/sap/bc/srt/wsdl/sdef_ZWS_TEST_UDAY_WEB/wsdl11/ws_policy/document?sap-client=800"

        .setRequestHeader "Accept-encoding", "zip"

        .send (sEnv)

        xmlDoc.LoadXML .responseText

        MsgBox .responseText

        End With

End Sub


I am getting the ERROR.Please find the attachment for the error.
Please guide me to over come the Error,
Thanks In Advance.
Regards
RR Padhan

CALL SAP WEB SERVICE FROM MS EXCEL 2010 using VBA

$
0
0

Hello All,

I have a requirement ,where  I have to call SAP web service through MS excel using VBA.

For that I have created RFC enabled Function Module and WEB service is created.

 

But I am getting an error. Please Find the attachment for the error.

 

I have share the code also.

 

 

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING


*"     VALUE(PROCESS_TYPE) TYPE  CRMT_PROCESS_TYPE

*"     VALUE(SUCCESS) TYPE  CRMT_PROBABILITY OPTIONAL

*"  EXPORTING

*"     VALUE(MESSAGE) TYPE  CHAR255

*"     VALUE(OBJECT_ID) TYPE  CRMT_OBJECT_ID

 
Code of WEB SERVICE
<?xml
version="1.0" encoding="utf-8"
?> 
+<wsdl:definitions
targetNamespace
="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions"
-<wsdl:documentation>
Importing parameter for WEB Service
<n0:ZcrmOrderMaintainUday xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">

<Phase>Str</Phase>

<ProcessType>Stri</ProcessType>

</n0:ZcrmOrderMaintainUday>
Code IN VBA(EXCEL)
Private Sub CommandButton1_Click()
  Dim sURL As String
    Dim sEnv As String
    Dim xmlhtp As New MSXML2.XMLHTTP40
    Dim xmlDoc As New DOMDocument
    sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
   
   sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
    sEnv = sEnv & "  <soap:Body>"
    sEnv = sEnv & "    <sdef_ZWS_TEST_UDAY_WEB xmlns=""http://ides.studynest.org/webservices" > ""
   sEnv = sEnv & " <DESC>Test Of Visit Reprot by Prasmi</DESC>"
    sEnv = sEnv & " <PROCESS_TYPE>LEAD</PROCESS_TYPE>"
    sEnv = sEnv & "    </sdef_ZWS_TEST_UDAY_WEB>"
    sEnv = sEnv & "  </soap:Body>"
    sEnv = sEnv & "</soap:Envelope>"
    
    With xmlhtp
        .Open "post", sURL, False
        .setRequestHeader "Host", "ides.studynest.org"
        .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
        .setRequestHeader "Accept-encoding", "zip"
        .send (sEnv)
        xmlDoc.LoadXML .responseText
        MsgBox .responseText
        End With
End Sub

I am getting the ERROR. Please find the attachment for the error.
Please guide me to over come the Error,
Thanks In Advance.
Regards
RR Padhan

Scripting with windows 8 or seven

$
0
0


Hello everybody

 

I use scripting to update data in SAP. the script open a txt.file and automatise some actions.

The scripting works fine with windows XP but on other computer in windows 8 or seven the script don't find the file. message : file not found.

I have update the sap gui 7.30 to package 10 but we had the same problem even if we execute SAP in administrator side.

 

Someone have an idea ?

 

Best reagrds

Bruno

F-03 Clearing - Data from Excel to SAP

$
0
0

Hi guys,

 

I am new to creating macro tools using excel VBA and SAP and I am studying on my own.

I just want to ask if you can help me with creating my macro tool for clearing in SAP tcode f-03 because we are having backlogs of open items and this would help.

 

Here is my recorded VBA from SAP.

 

If Not IsObject(application) Then

   Set SapGuiAuto = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(Connection) Then

   Set Connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session = Connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session, "on"

   WScript.ConnectObject application, "on"

End If

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").Text = "f-03"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").Select

session.findById("wnd[0]/usr/ctxtRF05A-AGKON").Text = "1992010"

session.findById("wnd[0]/usr/ctxtBKPF-BUDAT").Text = "07.09.2014"

session.findById("wnd[0]/usr/txtBKPF-MONAT").Text = "9"

session.findById("wnd[0]/usr/ctxtBKPF-BUKRS").Text = "lb01"

session.findById("wnd[0]/usr/ctxtBKPF-WAERS").Text = "USD"

session.findById("wnd[0]/usr/sub:SAPMF05A:0131/radRF05A-XPOS1[4,0]").SetFocus

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[0,0]").Text = "2000007080"

session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").Text = "2000007101"

session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").SetFocus

session.findById("wnd[0]/usr/sub:SAPMF05A:0731/txtRF05A-SEL01[1,0]").caretPosition = 10

session.findById("wnd[0]/tbar[1]/btn[16]").press

 

 

The data that I want to use is coming from my excel file. Below is the sample of the data.

 

 

Header 1Header 2Header 3Header 4Header 5Header 6
GL Account
Company code
YearCurrencyDocument numberClearing Date
181020570002014USD200032577709.09.2014
3400112282

 

After the pair of document numbers are cleared, I also want to copy the message from SAP saying that is cleared and paste it in Excel.

 

I hope I was able to give you a clear view of what I want to achieve.. I also want the script to loop until all updated document numbers are cleared.

 

Hope you could help guys!

 

Thanks alot!

Viewing all 522 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>