Monday, September 30, 2013

Ask Stackoverflow and Code Review

Greetings,

sometimes you just need a second pair of eyes to look at a problem, or a piece of code.

Enter stackoverflow.com, a question and answer site with some excellent folks answering almost every ABAP question.

For code review, there are not a lot of reviewers yet for ABAP code. But if you have doubts about your code, you are almost certain to get valuable feedback which you can take or leave.

Remember; your code should be DRY, blunt, boring and working.

Splitting strings to tabs

Greetings,

in my previous post you will find on help.sap.com some horrendous code to split a binary string into a internal table. Which is funny, since they provide this wonderful function:

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer     l_binary_string
      TABLES
        binary_tab it_binary_content.


The function analyze the size of the table you provide and does all the heavy lifting.

The counterpart for regular strings to a text table is here:

    CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
      EXPORTING
        text      l_text_string
      TABLES
        ftext_tab it_text_content.

Content Management and BSP

Greetings,

SAP has an answer for everything, including content management.
If you want to store a document in SAP via an HTTP interface, you can start here: 

http://help.sap.com/saphelp_nw04/helpdata/en/b9/e1623c046a9b67e10000000a11402f/content.htm

The code is fairly straightforward to follow, but does not work, at least not for me.
The reason is that SAMPLELOIO and SAMPLEPHIO are not real KW classes.

Instead you can decided to use KWN_GEN and KWN_GENSRC, you will get some errors then about missing properties which you can solve by adding those properties to loio_properties and phio_properties with some default value. The only exception to that is STORAGE_CATEGORY, I found that using the value DMS_C1_ST will do the trick.

I would suggest you store the class and the wa_phio-objid into a Z table for easy reference later. When you want to retrieve a stored file, you can simply use the code from here:

http://help.sap.com/saphelp_nw04/helpdata/en/74/a2623c2d6a1e66e10000000a11402f/content.htm