"-Begin-----------------------------------------------------------------
Program Z_TEST.
Write: / 'Hello World'.
"-End-------------------------------------------------------------------
FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(E_TAB_LISTZEILE) TYPE Z_TAB_LISTZEILE
*"----------------------------------------------------------------------
*" Z_TAB_LISTZEILE is a Table Type with the Line Type LISTZEILE
**----------------------------------------------------------------------
DATA lt_abaplist TYPE STANDARD TABLE OF abaplist.
DATA lt_listzeile TYPE STANDARD TABLE OF listzeile.
SUBMIT z_test EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = lt_listzeile
listobject = lt_abaplist
EXCEPTIONS
Others = 1.
IF sy-subrc = 0.
e_tab_listzeile = lt_listzeile.
ENDIF.
ENDIF.
ENDFUNCTION.
# -*- coding: iso-8859-15 -*-
#-Begin-----------------------------------------------------------------
#-Include---------------------------------------------------------------
FileName = "sapnwrfc.py"
exec(compile(open(FileName).read(), FileName, "exec"))
#-Sub Main--------------------------------------------------------------
def 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"
hRFC = SAP.RfcOpenConnection(RfcConnParams, 5, RfcErrInf)
if hRFC is not None:
charBuffer = create_unicode_buffer(256 + 1)
hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "Z_TEST", RfcErrInf)
if hFuncDesc != 0:
hFunc = SAP.RfcCreateFunction(hFuncDesc, RfcErrInf)
if hFunc != 0:
if SAP.RfcInvoke(hRFC, hFunc, RfcErrInf) == RFC_OK:
hTable = c_void_p(0)
if SAP.RfcGetTable(hFunc, "E_TAB_LISTZEILE", 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)
print(charBuffer.value.rstrip())
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)
#-Main------------------------------------------------------------------
if __name__ == "__main__":
main()
#-End-------------------------------------------------------------------
FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_TAB_RSPARAMS) TYPE RSPARAMS_TT OPTIONAL
*" EXPORTING
*" VALUE(E_TAB_LISTZEILE) TYPE Z_TAB_LISTZEILE
*"----------------------------------------------------------------------
DATA lt_abaplist TYPE STANDARD TABLE OF abaplist.
DATA lt_listzeile TYPE STANDARD TABLE OF listzeile.
SUBMIT rsusr002 WITH SELECTION-TABLE i_tab_rsparams
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = lt_listzeile
listobject = lt_abaplist
EXCEPTIONS
Others = 1.
IF sy-subrc = 0.
e_tab_listzeile = lt_listzeile.
ENDIF.
ENDIF.
ENDFUNCTION.
# -*- coding: iso-8859-15 -*-
#-Begin-----------------------------------------------------------------
#-Imports---------------------------------------------------------------
import os, platform
#-Include---------------------------------------------------------------
FileName = "sapnwrfc.py"
exec(compile(open(FileName).read(), FileName, "exec"))
#-Sub Main--------------------------------------------------------------
def 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"
hRFC = SAP.RfcOpenConnection(RfcConnParams, 5, RfcErrInf)
if hRFC is not None:
charBuffer = create_unicode_buffer(256 + 1)
hFuncDesc = SAP.RfcGetFunctionDesc(hRFC, "Z_TEST", RfcErrInf)
if hFuncDesc != 0:
hFunc = SAP.RfcCreateFunction(hFuncDesc, RfcErrInf)
if hFunc != 0:
hTable = c_void_p(0)
if SAP.RfcGetTable(hFunc, "I_TAB_RSPARAMS", hTable, RfcErrInf) == RFC_OK:
hRow = SAP.RfcAppendNewRow(hTable, RfcErrInf)
rc = SAP.RfcSetChars(hRow, "SELNAME", "USER", 4, RfcErrInf)
rc = SAP.RfcSetChars(hRow, "KIND", "S", 1, RfcErrInf)
rc = SAP.RfcSetChars(hRow, "SIGN", "I", 1, RfcErrInf)
rc = SAP.RfcSetChars(hRow, "OPTION", "EQ", 2, RfcErrInf)
rc = SAP.RfcSetChars(hRow, "LOW", "BCUSER", 6, RfcErrInf)
if SAP.RfcInvoke(hRFC, hFunc, RfcErrInf) == RFC_OK:
if SAP.RfcGetTable(hFunc, "E_TAB_LISTZEILE", 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)
print(charBuffer.value.rstrip())
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)
#-Main------------------------------------------------------------------
if __name__ == "__main__":
print("Python", platform.python_version(), "on",
platform.system(), "(" + platform.architecture()[0] + ")",
end="\n\n")
main()
print("\n")
os.system('pause')
#-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
2 | |
2 |