Tuesday, 3 February 2015

Can you get SAP onto a Mobile Phone?

Of course you can... That heading is just there because I get people asking me that quite frequently... There are dozens of articles out there about the different technologies, lots of them involving SAP Gateway, transaction SEGW, oData, Native/Hybrid Apps, Kapsel, Fiori, UI5 etc. 

All of the above are the SAP backed, "official" way of doing things. I've dealt with them with varying degrees of success, and they all have their own merits.

However...

The oft-overlooked and humble BSP is capable of serving up Web Pages.

guess what... your mobile phone can consume Web Pages...

Can you see where I'm going with this?

The problem with this approach thus far is that the HTMLb language that SAP uses in BSPs looks pretty crap on a mobile...

This is where jQuery comes in. jQuery is a library you can either download or just dynamically refer to (i.e. point your webpage at another webpage where the javascript lives).

This does some good stuff - it adjusts screen sizes, handles orientation changes, has some nice wizzy animations and generally behaves like you'd hope.

I've written a demo which works quite happily in BSP (albeit with harcoded data) and looks nice on both desktop and mobile. With a little extra work, it could be plumbed in to the backend...

Here are some screenshots from both desktop and mobile :

Desktop jQuery table : 
And the same on the phone in portrait mode:


 And in landscape mode:

Note the nice thing about this is that the table in portrait mode knows that the table is too wide to be sensibly output, and so displays it as a list. jQuery also gives you nice collapsible containers:


which you can nest if you want to:


And then you've got dropdown lists and forms...




The code for this is here : it's a little clumsy in that all the sub-screens are contained in the main BSP's html, and is an obvious case for some sub-division / segregation, but it does demonstrate a way of neatly getting a desktop/phone consistent application.

And if you're lucky enough to have a webdispatcher courtesy of your friendly BASIS team. then you can access your newly minted BSP from Starbucks... otherwise you'll need to navigate to the BSP address on your mobile phone (stick it as a bookmark before you forget) whilst connected to the same Wifi LAN that your SAP Server is on. This may or may not be an issue for you, depending on how "Mobile" you need your "App" (read web page served from a SAP Server) to be.

I was surprised at how quick it was to pick up (thanks again W3Schools!) and how pretty it looked with so little effort...

Here's the code, all 400 lines of it...

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>

<div data-role="page" id="callslist">
  <div data-role="header">
    <h1>Edenhouse CRM Report</h1>
  </div>

<%--  <div data-role="main" class="ui-content">
    <p>2Edenhouse CRM Report</p>
  </div>--%>

    <table data-role="table" class="ui-responsive">
      <thead>
        <tr>
          <th>Query#</th>
          <th>Area</th>
          <th>Description</th>
          <th>Status</th>
          <th>Owner</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><a href="#7-5525" data-transition="flip">7-5525</a></td>
          <td>HR</td>
          <td>Revise 2015 Payscales</td>
          <td>WIP</td>
          <td>Amanda Hugandkiss</td>
        </tr>
        <tr>
          <td><a href="#7-2534" data-transition="flip">7-2534</a></td>
          <td>MM</td>
          <td>Master Data MRP error</td>
          <td>PUT</td>
          <td>Tish Hughes</td>
        </tr>
        <tr>
          <td><a href="#7-9534" data-transition="flip">7-9534</a></td>
          <td>WM</td>
          <td>Stock Putaway running slowly</td>
          <td>PUT</td>
          <td>Jonny Tubbydigits</td>
        </tr>
        <tr>
          <td><a href="#7-1534" data-transition="flip">7-1534</a></td>
          <td>SD</td>
          <td>Foreign Currencies on Sales Orders</td>
          <td>WIP</td>
          <td>Claire Asday</td>
        </tr>
      </tbody>
    </table>



  <div data-role="footer">
    <h1>Footer Text</h1>
  </div>
</div>

<div data-role="page" id="7-5525">
  <div data-role="header">
    <h1>7-5525 : Revise 2015 Payscales</h1>
  </div>

  <div data-role="main" class="ui-content">
    <a href="#callslist">Back to Query List</a>
     <div data-role="main" class="ui-content">
    <div data-role="collapsible">
      <h1>Header Data</h1>
      <p>Customer : Acmeland</p>
      <p>Contact : David Baker</p>
      <p>Phone : <a href="tel:01234 567 890">07870553645</a></p>
      <p>Time Booked : 35 hours</p>
      <p>Time remaining : 27 hours</p>
      <p>Last updated : 30.01.2015</p>
    </div>
    <div data-role="collapsible">
      <h1>Query History</h1>
      <div data-role="collapsible">
        <h1>Patrick Dean 02.02.2015</h1>
        <p>Mailed Kaushal with the transport numbers, requested he re-test.</p>
      </div>
      <div data-role="collapsible">
        <h1>Angela Webster 01.02.2015</h1>
        <p>Assisted Patrick with FI documentation</p>
      </div>
      <div data-role="collapsible">
        <h1>Patrick Dean 30.01.2015</h1>
        <p>Logon Issues, registered with BASIS</p>
      </div>
    </div>
    <div data-role="collapsible">
      <h1>Add Activity</h1>

          <form method="post" action="demoform.asp">
      <div class="ui-field-contain">
        <label for="day">Activity Type :</label>
        <select name="day" id="day">
          <option value="AU">Activity Undertaken</option>
          <option value="IN">Internal Note</option>
          <option value="TX">Transports</option>
          <option value="SN">Solution</option>
        </select>
        <label for="status">Status</label>
        <select name="status" id="status">
          <option value="ASS">Assigned</option>
          <option value="CUA">Customer Action</option>
          <option value="CUT">Customer Testing</option>
          <option value="TOT">With Third Party</option>
          <option value="CLO">Closed</option>
          <option value="OPN">Open</option>
        </select>

        <label for="bday">Date of Activity</label>
        <input type="date" name="bday" id="bday">
        <label for="hoursbooked">Hours Booked</label>
        <input type="text" name="" id="hoursbooked">
        <label for="info">Notes</label>
        <textarea name="addinfo" id="info"></textarea>
      </div>
      <input type="submit" data-inline="true" value="Submit">
    </form>


    </div>


  </div>

  </div>

  <div data-role="footer">
    <h1>Footer Text in Dialog</h1>
  </div>
</div>

<!-- ********************Second Query -->

<div data-role="page" id="7-2534">
  <div data-role="header">
    <h1>7-2534 : Master Data MRP error</h1>
  </div>

  <div data-role="main" class="ui-content">
    <a href="#callslist">Back to Query List</a>
     <div data-role="main" class="ui-content">
    <div data-role="collapsible">
      <h1>Header Data</h1>
      <p>Customer : Tindlecrook</p>
      <p>Contact : Ian Spragg</p>
      <p>Phone : <a href="tel:01234 567 890">07917 631 418</a></p>
      <p>Time Booked : hours</p>
      <p>Time remaining : hours</p>
      <p>Last updated : 15.01.2015</p>
    </div>
    <div data-role="collapsible">
      <h1>Query History</h1>
      <div data-role="collapsible">
        <h1>James Corrigan 30.12.2015</h1>
        <p>VPNs needed re-configuring. This will need additional input from management</p>
      </div>
      <div data-role="collapsible">
        <h1>Jo Samuels 26.12.2015</h1>
        <p>Not deemed to be development call - please check OSS before assigning to development - reassigning to James</p>
      </div>
      <div data-role="collapsible">
        <h1>Patrick Dean 14.12.2015</h1>
        <p>Initial investigation Undertaken, no coding required.</p>
      </div>
      <div data-role="collapsible">
        <h1>Wojciech Haase 14.12.2015</h1>
        <p>Initial investigation Undertaken, no coding required. Going to get Paddy to check this for me...</p>
      </div>
    </div>
    <div data-role="collapsible">
      <h1>Add Activity</h1>

          <form method="post" action="demoform.asp">
      <div class="ui-field-contain">
        <label for="day">Activity Type :</label>
        <select name="day" id="day">
          <option value="AU">Activity Undertaken</option>
          <option value="IN">Internal Note</option>
          <option value="TX">Transports</option>
          <option value="SN">Solution</option>
        </select>
        <label for="status">Status</label>
        <select name="status" id="status">
          <option value="ASS">Assigned</option>
          <option value="CUA">Customer Action</option>
          <option value="CUT">Customer Testing</option>
          <option value="TOT">With Third Party</option>
          <option value="CLO">Closed</option>
          <option value="OPN">Open</option>
        </select>

        <label for="bday">Date of Activity</label>
        <input type="date" name="bday" id="bday">
        <label for="hoursbooked">Hours Booked</label>
        <input type="text" name="" id="hoursbooked">
        <label for="info">Notes</label>
        <textarea name="addinfo" id="info"></textarea>
      </div>
      <input type="submit" data-inline="true" value="Submit">
    </form>


    </div>


  </div>

  </div>

  <div data-role="footer">
    <h1>Footer Text in Dialog</h1>
  </div>
</div>


<!-- ********************Third Query -->

<div data-role="page" id="7-9534">
  <div data-role="header">
    <h1>7-9534 : Stock Putaway running slowly</h1>
  </div>

  <div data-role="main" class="ui-content">
    <a href="#callslist">Back to Query List</a>
     <div data-role="main" class="ui-content">
    <div data-role="collapsible">
      <h1>Header Data</h1>
      <p>Customer : Drummin Monkey</p>
      <p>Contact : Mark Curtis</p>
      <p>Phone : <a href="tel:01234 567 890">07917 631 418</a></p>
      <p>Time Booked : 10 hours</p>
      <p>Time remaining : 18 hours</p>
      <p>Last updated : 21.01.2015</p>
    </div>
    <div data-role="collapsible">
      <h1>Query History</h1>
      <div data-role="collapsible">
        <h1>Matt Cox 30.12.2015</h1>
        <p>Awaiting triage and resource from the Logistics team.</p>
      </div>
    </div>
    <div data-role="collapsible">
      <h1>Add Activity</h1>

          <form method="post" action="demoform.asp">
      <div class="ui-field-contain">
        <label for="day">Activity Type :</label>
        <select name="day" id="day">
          <option value="AU">Activity Undertaken</option>
          <option value="IN">Internal Note</option>
          <option value="TX">Transports</option>
          <option value="SN">Solution</option>
        </select>
        <label for="status">Status</label>
        <select name="status" id="status">
          <option value="ASS">Assigned</option>
          <option value="CUA">Customer Action</option>
          <option value="CUT">Customer Testing</option>
          <option value="TOT">With Third Party</option>
          <option value="CLO">Closed</option>
          <option value="OPN">Open</option>
        </select>

        <label for="bday">Date of Activity</label>
        <input type="date" name="bday" id="bday">
        <label for="hoursbooked">Hours Booked</label>
        <input type="text" name="" id="hoursbooked">
        <label for="info">Notes</label>
        <textarea name="addinfo" id="info"></textarea>
      </div>
      <input type="submit" data-inline="true" value="Submit">
    </form>


    </div>


  </div>

  </div>

  <div data-role="footer">
    <h1>Footer Text in Dialog</h1>
  </div>
</div>

<!-- ********************Fourth Query -->

<div data-role="page" id="7-1534">
  <div data-role="header">
    <h1>7-1534 : Foreign Currencies on Sales Orders</h1>
  </div>

  <div data-role="main" class="ui-content">
    <a href="#callslist">Back to Query List</a>
     <div data-role="main" class="ui-content">
    <div data-role="collapsible">
      <h1>Header Data</h1>
      <p>Customer : Daisies Doodles</p>
      <p>Contact : Nathan Binks</p>
      <p>Phone : <a href="tel:01234 567 890">07917 631 418</a></p>
      <p>Time Booked : 100 hours</p>
      <p>Time remaining : 180 hours</p>
      <p>Last updated : 22.01.2015</p>
    </div>
    <div data-role="collapsible">
      <h1>Query History</h1>
      <div data-role="collapsible">
        <h1>Laurie Walker 07.01.2014</h1>
        <p>Days on site - configuring local Currencies.
        </p>
      </div>
      <div data-role="collapsible">
        <h1>Laurie Walker 04.01.2014</h1>
        <p>Days on site - configuring local Currencies.
        </p>
      </div>
      <div data-role="collapsible">
        <h1>Laurie Walker 03.01.2014</h1>
        <p>Days on site - configuring local Currencies.
        Configuring pertinent company codes.
        </p>
      </div>
      <div data-role="collapsible">
        <h1>Laurie Walker 02.01.2015</h1>
        <p>Days on site - configuring local Currencies. Initial meetings with client to discuss requirements
        </p>
      </div>
      <div data-role="collapsible">
        <h1>Matt Cox 30.12.2014</h1>
        <p>Initial requirement received from customer : Wish to undergo full review of Sales Orders to allow
        foreign currencies in light of new acquisition of European department. Initially Euros, subsequently Danish Krona
        and Swiss Francs
        </p>
      </div>
    </div>
    <div data-role="collapsible">
      <h1>Add Activity</h1>

          <form method="post" action="demoform.asp">
      <div class="ui-field-contain">
        <label for="day">Activity Type :</label>
        <select name="day" id="day">
          <option value="AU">Activity Undertaken</option>
          <option value="IN">Internal Note</option>
          <option value="TX">Transports</option>
          <option value="SN">Solution</option>
        </select>
        <label for="status">Status</label>
        <select name="status" id="status">
          <option value="ASS">Assigned</option>
          <option value="CUA">Customer Action</option>
          <option value="CUT">Customer Testing</option>
          <option value="TOT">With Third Party</option>
          <option value="CLO">Closed</option>
          <option value="OPN">Open</option>
        </select>

        <label for="bday">Date of Activity</label>
        <input type="date" name="bday" id="bday">
        <label for="hoursbooked">Hours Booked</label>
        <input type="text" name="" id="hoursbooked">
        <label for="info">Notes</label>
        <textarea name="addinfo" id="info"></textarea>
      </div>
      <input type="submit" data-inline="true" value="Submit">
    </form>


    </div>


  </div>

  </div>

  <div data-role="footer">
    <h1>Footer Text in Dialog</h1>
  </div>
</div>





</body>
</html>










Tuesday, 23 December 2014

Cloud For Customer Training - WDC4C - Review

So, the good people at Edenhouse decided to send me on some Cloud For Customer development training. Aside from the premium experience that SAP offer at their training facilities, and some time away from my lovely family, this was a great chance to try out some of the new C4C development environment.

My first impressions are that you can develop quite a lot of stuff in quite a short period of time. I think it's a lot like Apple products - what they do do, they do incredibly well - but I can already see the limitations...more on that later.

Just by creating an object in the ABAP Scripting Language (ABSL), and running a few wizards, you have a variety of CRUD operations, a table, and query facilities. It was all mind-blowingly quick to develop. I think this will satisfy lots of end users, and they can just get on with their business processes.

I can, however imagine a lot of users saying "Can you make it do...<insert esoteric request here>" and we'll have to just say "No".

It can call WebServices though... this is where it'll get super-good. We'll WS to the R3 backend, and then we'll have the best of both worlds!

I've not got my own development environment yet, so can't do any vids or tuts, but as soon as I've got it together, I'll throw some material up.

Oh, and by the way, Happy Christmas Everyone!!

Thursday, 20 November 2014

Squishing an unpredictable address structure...

We've all been there - address structures can be unpredictable, and you need to output them in a consistent format... The following ABAP code sample allows you to take the ADRC structure, put them into some kind of priority, split into a table, ignore the blank lines, and then concatenate into the final target field...

typesbegin of tty_addr,
        addrline type char255,
       end of tty_addr.

datat_addrlines type table of tty_addr,
      w_addrlines type tty_addr.

dataw_adrc type adrc.


select single from adrc into w_adrc where ADDRNUMBER = l_adrnr.
check sy-subrc 0.

concatenate w_adrc-name_text
            w_adrc-street
            w_adrc-city1
            w_adrc-STR_SUPPL1
            w_adrc-STR_SUPPL2
            w_adrc-STR_SUPPL3
            w_arc-POST_CODE1
            w_arc-POST_CODE2
            w_arc-POST_CODE3
"Whatever fields MIGHT be populated from ADRC...

into l_DispatchAddress separated by '<&,>'.

split l_DispatchAddress at '<&,>' into table t_addrlines.
clear l_DispatchAddress.

loop at t_addrlines into w_addrlines.
  if w_addrlines is not initial.
    concatenate l_DispatchAddress w_addrlines-addrline into l_DispatchAddress separated by ', '.
  endif.
endloop.


Wednesday, 29 October 2014

Stupid Flowerboxes

This one is roughly the same size as the form it's describing, and tells us absolutely nothing useful. Needless to say I scrubbed this pollution as quickly as I could, and got on with my code... (after ShamingButNotNaming on my blog, of course...)


Tuesday, 28 October 2014

Iterate Up the HR Structure

Thanks to Kat for this one... I've got to get the UserID of the Users Manager... trouble is, sometimes the OrgStructure positions aren't filled - so I have to see who's sitting in the position. If there's no-one in it, then I loop back round and get the OrgStructure's superior position (since there's no Personnel person to check on!). I repeat this until I find someone, and stop at 20 goes... If this has happened, it's either 

the guy at the top of the tree (we try 20 times to work out if the guy has a useful boss, but fail because it's Paul Solomon :) 

OR

there's such a massive Org Structure that's not populated with stuff, that you should probably question what the point of the structure is!!

do 20 times.  "Don't want to infinite loop...
refresh t_leadpos.
CALL FUNCTION 'RH_GET_LEADING_POSITION'
    EXPORTING
      plvar            w_plvar
      otype            l_otype  "can be US (user), P (Person), S (position) or O (Org unit)
      sobid            l_sobid
      date             sy-datum
      auth             ' '
    TABLES
      leading_pos    t_leadpos
    EXCEPTIONS
      no_lead_pos_found  1
      OTHERS             2.

check t_leadpos[] is not initial.
read table t_leadpos into w_leadpos index 1.

      REFRESH t_holders.
      CALL FUNCTION 'HRWPC_RFC_PP_HOLDERS'
        EXPORTING
          plvar           w_plvar          "usually 01
          otype           'S'
          objid           w_leadpos-objid   "from above table read
        TABLES
          holder          t_holders
        EXCEPTIONS
          no_active_plvar 1
          infty_not_found 2
          nothing_found   3
          OTHERS          4.

      IF sy-subrc AND t_holders IS NOT INITIAL.

        READ TABLE t_holders INTO w_holders INDEX 1.

      read table t_pa0105 into w_pa0105 with key pernr w_holders-pernr
                                                  subty '0001'.
      if sy-subrc 0.
          p_output-manager w_pa0105-usrid.
          exit.
      endif.

      else"Didn't find holders for the position... Go and find the Super-Position.
         l_otype w_leadpos-otype"Probably 'S' but hey, let's make it dynamic.
         l_sobid w_leadpos-objid.
      endif.  "Found holders for the position.

enddo"Iterate up the structure.

Tuesday, 14 October 2014

Creating an Invoice...

Clearly you'll need to make sure that the GLAccounts, Payment Terms etc exist, but feel free to use this as a template to create your Invoices...


*&---------------------------------------------------------------------*
*&  Include           Z_PD_CAPS1_DEMOS_INV_CREATE                      *
*&---------------------------------------------------------------------*

data:
obj_type like bapiache02-obj_type,
obj_key like bapiache02-obj_key,
obj_sys like bapiache02-obj_sys,
documentheader like bapiache09,

accountgl like bapiacgl09 occurs 0 with header line,
tax_accountgl like bapiacgl09 OCCURS 0 WITH HEADER LINE,
currencyamount like bapiaccr09 occurs 0 with header line,
tax_currencyamount like bapiaccr09 OCCURS 0 WITH HEADER LINE,
return like bapiret2 occurs 0 with header line,
extension1 like bapiextc occurs 0 with header line,

t_edidd like edidd occurs 0 with header line,
bapi_retn_info like bapiret2 occurs 0 with header line.
data: error_flag.
data: wa_akont TYPE akont.

data: t_accountreceivable TYPE TABLE OF BAPIACAR09 WITH HEADER LINE.
datA: T_MWDAT TYPE TABLE OF RTAX1U15 WITH HEADER LINE.
data: wa_wrbtr type wrbtr.
data: curr_li TYPE POSNR_ACC.
data: v_tabix like sy-tabix.


documentheader-username = sy-uname.
documentheader-header_txt = 'Test using BAPI'.
documentheader-comp_code = 'CF01'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'SA'.
documentheader-REF_DOC_NO = 'INVOICE_01'.

clear accountgl.
clear wa_akont.

t_accountreceivable-ITEMNO_ACC = '1'.
t_accountreceivable-customer = 'C524'.
"t_accountreceivable-TAX_CODE = 'A1'.
t_accountreceivable-gl_account = '0000400000'.
t_accountreceivable-PMNTTRMS = 'Z030'.
t_accountreceivable-ALLOC_NMBR = 'LORDS0820'.
t_accountreceivable-ITEM_TEXT = 'Facility Name'.
append t_accountreceivable.


accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000802010'.
accountgl-comp_code = 'CF01'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000069314'.
"accountgl-costcenter = '0069314001'.
accountgl-ITEM_TEXT = 'Item Text'.
accountgl-ORDERID = 'LORDS0820'.
accountgl-TAX_CODE = 'A0'.
append accountgl.

clear accountgl.
accountgl-itemno_acc = '3'.
accountgl-gl_account = '0000802010'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = accountgl-gl_account
 IMPORTING
   OUTPUT        = accountgl-gl_account.

accountgl-ITEM_TEXT = 'Item Text'.
accountgl-ORDERID = 'LORDS0820'.
accountgl-comp_code = 'CF01'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-TAX_CODE = 'A1'.
append accountgl.

clear accountgl.
accountgl-itemno_acc = '4'.
accountgl-gl_account = '0000711350'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = accountgl-gl_account
 IMPORTING
   OUTPUT        = accountgl-gl_account.
          .

accountgl-comp_code = 'CF01'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-TAX_CODE = 'V0'.
accountgl-costcenter = '69314001'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = accountgl-costcenter
 IMPORTING
   OUTPUT        = accountgl-costcenter.

append accountgl.

currencyamount-itemno_acc = '1'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '470.00'.
append currencyamount.

currencyamount-itemno_acc = '2'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-230.00'.
append currencyamount.

currencyamount-itemno_acc = '3'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-235.00'.
append currencyamount.

currencyamount-itemno_acc = '4'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-5.00'.
append currencyamount.

"PD We're now calculating the tax. Need to calculate any tax at the
"appropriate rate.

"work out the first line that tax can go on.
loop at accountgl.
endloop.
curr_li = accountgl-ITEMNO_ACC.
curr_li = curr_li + 1.

loop at accountgl.
  READ TABLE currencyamount with key ITEMNO_ACC =
accountgl-ITEMNO_ACC.
  check sy-subrc = 0.
  v_tabix = sy-tabix.
  wa_wrbtr = currencyamount-amt_doccur.
  CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
    EXPORTING
      I_BUKRS = accountgl-comp_code
      I_MWSKZ = accountgl-TAX_CODE
      I_WAERS = currencyamount-currency
      I_WRBTR = wa_wrbtr
    TABLES
      T_MWDAT = t_mwdat
    EXCEPTIONS
      BUKRS_NOT_FOUND = 1
      COUNTRY_NOT_FOUND = 2
      MWSKZ_NOT_DEFINED = 3
      MWSKZ_NOT_VALID   = 4
      ACCOUNT_NOT_FOUND = 5
      DIFFERENT_DISCOUNT_BASE = 6
      DIFFERENT_TAX_BASE            = 7
      TXJCD_NOT_VALID               = 8
      NOT_FOUND                     = 9
      KTOSL_NOT_FOUND               = 10
      KALSM_NOT_FOUND               = 11
      PARAMETER_ERROR               = 12
      KNUMH_NOT_FOUND               = 13
      KSCHL_NOT_FOUND               = 14
      UNKNOWN_ERROR                 = 15
      OTHERS                        = 16.

IF SY-SUBRC <> 0.
 CONTINUE.
ENDIF.

READ TABLE T_MWDAT INDEX 1.
check sy-subrc = 0.
"There was tax there!!
if t_mwdat-wmwst is not INITIAL.
clear tax_accountgl.
tax_accountgl-gl_account = '402560'.
tax_accountgl-ITEMNO_ACC = curr_li.
tax_accountgl-tax_code = accountgl-tax_code.


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = tax_accountgl-gl_account
 IMPORTING
   OUTPUT        = tax_accountgl-gl_account.

append tax_accountgl.



clear tax_currencyamount.
tax_currencyamount = currencyamount.
tax_currencyamount-amt_doccur = T_MWDAT-wmwst.
tax_currencyamount-ITEMNO_ACC = curr_li.
append tax_currencyamount.

currencyamount-amt_doccur = T_MWDAT-KAWRT.
modify currencyamount index v_tabix.

curr_li = curr_li + 1.

endif.
endloop.

append LINES OF tax_accountgl to accountgl.
append LINES OF tax_currencyamount to currencyamount.


CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    DOCUMENTHEADER          = documentheader
  TABLES
    ACCOUNTGL               = accountgl
    ACCOUNTRECEIVABLE       = t_accountreceivable
    CURRENCYAMOUNT          = currencyamount
    RETURN                  = return          .


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 EXPORTING
    WAIT          = 'X'.


loop at return.
  write return-message.
endloop.

Tuesday, 26 August 2014

Getting the Buffer Quality metric from an Oracle System

The requirement was to try and get the “Buffer Quality” value out of BASIS transaction ST04. The technique for this will vary from system to system, as it depends on the underlying database.


The field behind this is DBUFF_QUALITY and ST04 is underpinned by program RSDB0004.

A quick look at this tells us that RSDB0004 is just a CASE Statement that filters the Database System, and calls corresponding transactions. The one I’m interested in is an Oracle Database:


Going into this, I did a search on “DBUFF_QUALITY” and found that it was held in function module

C_ORA_MM_GET_DATA_V10.

I ran this in SE37, without any parameters populated, and in the response, there was a structure called S_ST04N_DATA with parameter DBUFF_QUALITY which is what I was after.

Nice and Simple!