Get SMQ queues in Python?

115 Views Asked by At

I'm using the PYRFC library and so far I've managed to connect to SAP.

conn = Connection(ashost='xxxxxxxxx', sysnr='02', client='100', user='xxxxx', passwd='xxxxxxxx.')
result = conn.call('STFC_CONNECTION', REQUTEXT=u'Hello SAP!')
print (result)

I did the connection test and everything was ok. But now I'm trying to run the queues created in SAP.

enter image description here

I performed some tests, trying to simulate the F8 but without success. Is there any way to make this execution using via python?

1

There are 1 best solutions below

0
Suncatcher On

Directly you cannot query SMQ1/2 results, for an extended explanation read my answer here.

To get the SMQ results in Pyton you need to find a module with an equivalent functionality, and good news pa-pam!, I did it for you: this is TRFC_QIN_GET_CURRENT_QUEUES function module.

How to call you can find it in any pyrfc tutorial. Probable sample:

def func():
    import pyrfc
    from pyrfc import Connection
    conn=pyrfc.Connection(user='', passwd='', ashost='', etc.)

    queue_name = '*'
    client     = '100'

    result=con.call("TRFC_QIN_GET_CURRENT_QUEUES", qname=queue_name, 
                                                   client=client)
print(result['QVIEW'])

all you need to put here is queue name (qname parameter) and client value (what is it?).