cancel
Showing results for 
Search instead for 
Did you mean: 

Web based booking in of service orders

Former Member
0 Kudos

A company I have recently been doing work for approached me with a interesting request. They wanted a method for users to be able to book in service orders themselves, online. Vendors were not being paid on time due to the fact acknowledgment of receipt of the orders was not given in a timely fashion.

Not everyone had access to SAP for cost reasons. Also quite a few people for some reason do not like the SAP interface. The spreadsheet they generated based on a SAP report was also proving ineffective due to users overwriting acknowledged orders.

With this in mind, Myself and the local ABAP programmer came up with the following solution.

The main ingredients of the solution involve the following:

1)Windows Active Directory

2)IIS, PHP

3)BAPI_GOODSMVT_CREATE,BAPI_TRANSACTION_COMMIT,BAPI_TRANSACTION_ROLLBACK

A Windows 2000 Intranet server was setup with PHP and the SAPRFC extension. Using Windows authentication we now select the correct recipient for the outstanding service orders report. The local ABAP programmer wrote a function to allow me to pass the username as a import parameter and receive the lines of outstanding orders in JTAB which I can pull off into an array using saprfc_table_read.

Here is an overview of how this works. I don't have the script in front of me. So I'm doing this from memory. I will add some more code specific detail at a later date.

1)PHP script calls local bespoke RFC function and sends RECIPENT (username) as an import parameter. RFC function fills JTAB with outstanding orders. Items in JTAB table are LIFNR,NAME1,EBELN,EBELP,TXZ01,EINDT,OPENQTY,MEINS,NETPR,WAERS,WEMPF. Each line is then read in a loop using the number of rows returned by saprfc_table_rows.

2)The user is then presented with a form which allows them to acknowledge orders to the maximum value of OPENQTY for each line item.

3)On submission the lines are sorted by vendor. We have to run the BAPI's multiple times for each vendor. You can't book in line items from different vendors in one go. Once this is done we can start calling our BAPI's to book the items in.

4)We setup a loop by vendor which does the following:

Call BAPI_GOODSMVT_CREATE and set the import parameters GOODSMVT_HEADER & GOODSMVT_CODE.

<code>

/* Please note this is not runnable code. It's code just to get a feel of whats going on. You will need to fill in the details */

$goodsmvt_header = array('PSTING_DATE' => '20050512',

'DOC_DATE'=> '20050512',

'REF_DOC_NO'=> 'Jsimmons');

$goodsmvt_code = array('GM_CODE' => '01');

/* $fhandle is from a connection we established earlier using saprfc_open & saprfc_function_discover */

saprfc_import($fhandle,'GOODSMVT_HEADER',$goodsmvt_header);

saprfc_import($fhandle,'GOODSMVT_CODE',$goodsmvt_code);

/*

we now need to specify what items we wish to book in We have an array of line items associated with the current vendor in the outer loop which looks like this:

$lineitem = array('PO_NUMBER' => 'ponumber_from_user_form',

'PO_ITEM'=> 'poitem_from_user_form',

'MOVE_TYPE'=> '101',

'MVT_IND'=> 'B',

' ENTRY_QNT'=> ,'number_to_book_in_from_user_form');

*/

saprfc_table_init($fhandle,'GOODS_MVT_ITEM');

foreach ($alllineitems as $lineitem) {

saprfc_table_append($fhandle,'GOODS_MVT_ITEM',$lineitem);

// check for errors using saprfc_error

}

/* Now we need to call our first BAPI to post the items */

$errorcode = saprfc_call_and_receive ($fhandle);

// Insert Error handling code in here

/* If the RESULTS table has entries , We have a problem */

if (saprfc_table_rows($fhandle,'RESULTS'){

$fhandle = saprfc_function_discover($rfcconnection,'BAPI_TRANSACTION_ROLLBACK');

$errorcode = saprfc_call_and_receive ($fhandle);

// Insert Error handling code in here

}else {

$fhandle = saprfc_function_discover($rfcconnection,'BAPI_TRANSACTION_COMMIT');

$errorcode = saprfc_call_and_receive ($fhandle);

// Insert Error handling code in here

}

saprfc_function_free($fhandle);

saprfc_close($rfconnection);

// Start loop again for next vendor

</code>

The overall results is that we now have a intranet application which allows users to easlily book in services orders. I even created a script which nags users via email to book in services orders. The nag email contains a link to the intranet page which contains the application.

Benefits:

1)Extremely cheap solution using every day tools

2)Browser based interface which everyone knows how to use.

3)Vendors are paid on time which allows the company to trade on more favorable terms.

4)Reduced administrator workload chasing people and making spreadsheets to capture outstanding service orders

I would recommend going through some of the documentation for the SAPRFC extension. This will give you an idea of what I'm trying to convey here, and fill in the gaps.

http://saprfc.sourceforge.net/src/saprfc.html

Have fun !

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Very nice Jason!! You should turn this into a weblog and post a link to the weblog in this message thread:

marilyn_pratt
Active Contributor
0 Kudos

Jason,

Craig is correct, your posting would make an excellent weblog. Perhaps creating an accurate step-by-step with actual code would be the way to go. You certainly will be rewarded with contribution points for your effort!

To become a weblogger just visit Submit Content in the upper Nav level. https://www.sdn.sap.com/sdn/weblogs.sdn?node=linkwnode3-6&contenttype=url&content=/irj/servlet/prt/p... and request to be a weblogger. After filling out the template you will be approved.

Craig,

You seem to be doing a fantastic job of moderating and encouraging the activity in these threads. This will be rewarded as well!

thanks,

Marilyn

SDN Community Manager

Former Member
0 Kudos

Just trying to do my part Marilyn

Oh could you do me a favor and lock the "Disappointment in " thread, it's moving towards a very postive topic and I think it'd be great to have that started as a new thread and not just added on to the current ? What do you think?

marilyn_pratt
Active Contributor
0 Kudos

Yes Craig,

I can certainly "lock" the thread and move the positive contents to a new thread.

My policy in the threads is to tread lightly (thread lightly) keep a watchful eye, quietly prod when needed (sometimes offline), and step back when I see participants showing incredible initiative, passion, commitment and contribution.

Would that be you and your colleagues here by any chance?

By the way, your behavior here Craig, exemplifies what being a good online host means: http://www.rheingold.com/texts/artonlinehost.html

This is one of my favorite definitions of great hosting.

Thanks for bringing this subject to life.

Marilyn

Former Member
0 Kudos

nice definition I've not heard that put so well before and thank you

Again I think we all do our parts the best we can and when you leave a community to itself especially this one it tends to take care of itself as well as bring the new children (PHP forum) up to speed as well

There are some lively people in here and I look forward to hearing what they have to say and hopefully we'll all inspire together more individuals to join in!

Former Member
0 Kudos

Yep I will do. I also have a couple more articles in the pipeline. I have also applied to be a weblogger on SDN after Marilyn's invite.

Former Member
0 Kudos

Excellent I look forward to reading them!!!