Maximo 7.6 APPR POs via Integration - automation

We have an integration where in PO will be created in an external application and then will be interfaced to Maximo.
POs which are aproved only will be inbound to Maximo , however Maximo doesnt allow addition of POLINES in APPR status ,so via integration , we are receiving the PO in WAPPR status.
We have to approve the PO instantly so that any successive PO updates / Receipt transactions process to Maximo.
I'm aware that an escalation can do the task of approving POs, however I would like the status change to happen instantly.
I have tried following options
1)Create a workflow to approve PO and set it to auto initiate. This doesnt work as workflow set to auto-initiate doesnt get triggered for objects created through integration
2)Tried setting up automation script to initiate workflow
from psdi.mbo import MboConstants
from psdi.server import MXServer
print("**************Script to Approve Inbound POs *******");
stat=mbo.getString("STATUS")
if ( stat != ''):
print ( " Status is not null ");
print ( stat);
if ( stat=='WAPPR'):
print ("Status is WAPPR");
MXServer.getMXServer().lookup("WORKFLOW").initiateWorkflow("[my WF]",mbo);
print(" Workflow has been initiated and PO will be approved");
my WF contains an Action , which performs Change Status to set status as APPR.
This creates an entry in the POSTATUS table, however new Status reads as WAPPR instead of APPR
3)Automation script to set value for Status
from psdi.mbo import MboConstants
from psdi.server import MXServer
print("**************Script to Approve POs Inbound *******");
stat=mbo.getString("STATUS")
if ( stat != ''):
print ( " Status is not null ");
print ( stat);
if ( stat=='WAPPR'):
print ("Status is WAPPR");
mbo.setValue("STATUS","APPR",MboConstants.NOVALIDATION );
print(" Status approved");
This was set up with Object Launch point , Object as PO and on Save operation , After commit.
This also dint work.
Please let me know whether there are any other options

Not sure if you're workflow triggering script is working or if it is needed.
The problem is you analysis of the change status. Because a new PO record is created, there is also a new status 'change', which is the change from 'nothing' to the first status for PO that is 'WAPPR' . For PO there is no 'NEW' status. So the record you're seeing in the POSTATUS table is not from your script, but from the create action of the interface.
For status changes you should use the default application action. This will change the status on the record AND create an entry in the correct status table (POSTATUS in this case). Go to->System Configuration->Platform configuration->Actions. Create new action. Set object to PO, Type to 'Change Status' and value to 'APPR'.
Use this action in your workflow. Or directly in the escalation.
Don't worry to much about escalations that run every 5min. You can even use a new status 'NEW' as synonym for 'WAPPR' to distinguish between normal records and the just interfaced ones. That way you can also hide them from your users in the PO application.
Hope that helps.

Related

Odoo create stock.move.line

when i try to create stock move line in transfer with automation with the following code, error pop up saying "psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block".
The code:
result=[]
result.append(
{'company_id':record.partner_id.id,
'date':record.date,
'location_dest_id':5,
'location_id':8 ,
'product_uom_qty':1,
'product_uom_id':32,
'product_id':465
})
env['stock.move.line'].create(result)
May I ask any idea what is the problem with my code or how can i programmtically create stock move line. Thanks
You set the company_id to the partner_id which may not be present in res.company table and
if it happens you should see the following error message:
DETAIL: Key (company_id)=(...) is not present in table "res_company".
This will prevent Odoo from creating a stock move line, try to set the company_id to self.env.user.company_id.id
Note that since v12 Odoo supports passing a list of values to create function

VA01 BDC_OKCODE /00 not working as expected

In my report I am calling the transaction VA01 with BDC data, and everything works as expected, the data is being filled correctly, but bdc_okcode /00 does not work.
I simply add the ok-code to the internal table:
gs_bdcdata-fnam = 'BDC_OKCODE'.
gs_bdcdata-fval = '/00'.
APPEND gs_bdcdata TO gt_bdcdata.
...
CALL TRANSACTION 'VA01' USING gt_bdcdata.
I get a popup that shows the ok code.
My expectation is that it should navigate to the next dynpro.
Also I tried to record the transaction through the transaction SHDB to see if I have to do something differently but the BDC data is basically the same. Playing back the recording shows the same popup with the code.
How can I solve that?
The MODE addition is not used by the CALL TRANSACTION.
If one of the additions MODE or OPTIONS FROM is not used, the effect is the same as if mode had the content "A". Which means the call transaction stops by each screen.
It has to be called like this:
DATA lv_mode TYPE char1 VALUE 'N'. "N - BI won't stop, E - will stop by error, A - will stop at every screen
CALL TRANSACTION 'VA01'
USING gt_bdcdata
MODE lv_mode.
A better option is to use the OPTIONS FROM addition, this gives you more opportunities:
DATA: ls_options TYPE ctu_params.
ls_options-dismode = 'N'. "see explanation above
CALL TRANSACTION 'VA01'
USING gt_bdcdata
OPTIONS FROM ls_options.

Can a telegram bot block a specific user?

I have a telegram bot that for any received message runs a program in the server and sends its result back. But there is a problem! If a user sends too many messages to my bot(spamming), it will make server so busy!
Is there any way to block the people whom send more than 5 messages in a second and don't receive their messages anymore? (using telegram api!!)
Firstly I have to say that Telegram Bot API does not have such a capability itself, Therefore you will need to implement it on your own and all you need to do is:
Count the number of the messages that a user sends within a second which won't be so easy without having a database. But if you have a database with a table called Black_List and save all the messages with their sent-time in another table, you'll be able to count the number of messages sent via one specific ChatID in a pre-defined time period(In your case; 1 second) and check if the count is bigger than 5 or not, if the answer was YES you can insert that ChatID to the Black_List table.
Every time the bot receives a message it must run a database query to see that the sender's chatID exists in the Black_List table or not. If it exists it should continue its own job and ignore the message(Or even it can send an alert to the user saying: "You're blocked." which I think can be time consuming).
Note that as I know the current telegram bot API doesn't have the feature to stop receiving messages but as I mentioned above you can ignore the messages from spammers.
In order to save time, You should avoid making a database connection
every time the bot receives an update(message), instead you can load
the ChatIDs that exist in the Black_List to a DataSet and update the
DataSet right after the insertion of a new spammer ChatID to the
Black_List table. This way the number of the queries will reduce
noticeably.
I have achieved it by this mean:
# Using the ttlcache to set a time-limited dict. you can adjust the ttl.
ttl_cache = cachetools.TTLCache(maxsize=128, ttl=60)
def check_user_msg_frequency(message):
print(ttl_cache)
msg_cnt = ttl_cache[message.from_user.id]
if msg_cnt > 3:
now = datetime.now()
until = now + timedelta(seconds=60*10)
bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=until)
def set_user_msg_frequency(message):
if not ttl_cache.get(message.from_user.id):
ttl_cache[message.from_user.id] = 1
else:
ttl_cache[message.from_user.id] += 1
With these to functions above, you can record how many messages sent by any user in the period. If a user's messages sent more than expected, he would be restricted.
Then, every handler you called should call these two functions:
#bot.message_handler(commands=['start', 'help'])
def handle_start_help(message):
set_user_msg_frequency(message)
check_user_msg_frequency(message)
I'm using pyTelegramBotAPI this module to handle.
I know I'm late to the party, but here is another simple solution that doesn't use a Db:
Create a ConversationState class to attach to each telegram Id when they start to chat with the bot
Then add a LastMessage DateTime variable to the ConversationState class
Now every time you receive a message check if enought time has passed from the LasteMessage DateTime, if not enought time has passed answer with a warning message.
You can also implement a timer that deletes the conversation state class if you are worried about performance.

Initialization of query failed - BW_REPORTING_FPM001 error

I am implementing Trial Balance(Version 2) FPM/Webdynpro App from Fiori Apps Library
following App Implementation : Trial Balance guide for S/4 Hana 1610.
When I launch the Trial Balance App.It says "Initialization of query 2CCFITRIALBALQ0001 Failed"(PFA for the error ).
Please let me know how to Initialize or Activate BEx Query.
Regards,
Sayed
The issue is resolved following the below steps :
1) Set a BW-client: Transaction SE37 RS_MANDT_UNIQUE_SET. If you use only one client, then fill I_MANDT with this one. If you use multiple clients, choose one of these.
2) Set user parameters RSWAD_DEV_MDVERSION = ‘072’ and RSWAD_SKIP_JAVA = ‘X’ for user DDIC(Its setting in transaction SU01 under parameter tab)
3) Logon to system with user DDIC in the client you used in step 1 and perform transaction RSTCO_ADMIN in order to activate the technical objects, which are needed for the engine. The parameters set in step 2 avoid, that unnecessary objects (related to BI tools based on JAVA) are activated here.
4) If you don't look at the OLAP-statistics you should deactivate these: Transaction SE38 - execute Report SAP_RSADMIN_MAINTAIN: with OBJECT = RSDDSTAT_GLOBAL_OFF and VALUE = X in insert mode. If you need the statistics, you can switch these on by running the program with that object but VALUE = space in update mode.
5) If you want to use OData-Services run report EQ_RS_AUTO_SETUP (transaction SE38)
6) If you want to use the BW time hierarchies, go to transaction RSRHIERARCHYVIRT and mark the hierarchies you need - for this you have to wait until the job triggered in step 3 has finished successfully
7) Call function module RSEC_GENERATE_BI_ALL.
Regards,
Rehan Sayed

Replicator Activity in sequential Mode for Approval WorkFlow in SharePoint 2010

I am trying to create a Dcoument Approval WorkFlow, with Custom Task Edit infopath forms
Flow is ,When A Document is added into the List , it is assingned to User A , who is Orignator's Manager.
When User A Approves the document , it Assigned to User B for Approval.User B is fixed.
When User B has approved the document , then User B himself will assign the document to User C(Which means User C is dynamic and will be there at runtime).
When User C Approves it , A Task should be created for User , and work Flow should continue till User C Completes his Task.
Is Any of the Users , rejects the Task, The Workflow Should Stop.
How I implmented it ;
I created one Sequence Activity , as follows :
-create Task
-whileTaskNotComplete (onTaskChanged)
Complete Task
then Placed this Activity under Replicator Activity.
I am not sure how to set Replicator initialized and Child initialzed values .
I know replicator needs to be run for 3 times, but the last iterations value is not fixed, it is provided at runtime under second iteration.and under onTaskChange event of Activity.
How can I pass this value to workflow or next iteration?
second thing when i am setting any value for Apporver under replicator initialized method , it is assigning all the Tasks to same Approver which is set under initialized method.
could you please help me , I referred the videos http://www.shillier.com/Videos/MultipleTasks.wmv, but it is for Parallel mode , I need in sequential mode.
Thanks in advance.
Azra
I would start splitting it up in a state machine:
1 Start
2 Create and Assign Task
3 Wait for approval
4 End
in the "Wait for approval" you check for your conditions and then set a global variable for the next approver in line (make sure it's persisted) and set the state to "Create and Assign Task". Until you are done with your list.
1->2->3->(->2)->4