May 28, 2005
STRING and XSTRING
Something I find very frustrating with ABAP (the new incarnation) is that it is so hard to do the simple things. For example, just the other day I needed to switch some character data from internat table => XSTRING. So how would you go about that?
What I ended up with this (unsatisfactory) solution, and I'm still thinking "surely it has to be easier than this?".
... data: i_pdf type table of tline, w_pdf type tline, w_stringdata type string, w_bindata type xstring, ... loop at i_pdf into w_pdf. concatenate w_stringdata w_pdf into w_stringdata. endloop. perform convertString2XString using w_stringdata changing w_bindata. ... data: lr_conv_ce type ref to CL_ABAP_CONV_OUT_CE. form convertString2XString using s type string changing xs type xstring. data: size type i. if lr_conv_ce is initial. lr_conv_ce = CL_ABAP_CONV_OUT_CE=>CREATE( ). else. call method lr_conv_ce->RESET( ). endif. call method lr_conv_ce->WRITE exporting data = s importing len = size. xs = lr_conv_ce->Get_Buffer( ). endform.
Now given all that - I sincerely hope that I have missed something somewhere, but I suspect that I haven't.
Now that ABAP has entered the 20th century, with moving away for a strictly fixed length storage basis (don't you love the fresh smell of COBOL in the morning ...:-), with the advent of character string, and binary data support - it has to go one major step forward, with better DWIM (Do What I Mean) conversion between native data types using the standard enables of MOVE, =, CONCATENATE, ASSIGN etc. We shouldn't have to jump through hoops, such as above to do the ordinary dross of programming that other (arguably more modern) languages do such as Perl ($bindata = join("",@tab_of_charstrings); ).
Posted by PiersHarding at May 28, 2005 8:23 PM
$bindata = "@tab_of_charstrings";
Posted by: DJ at May 28, 2005 9:33 PM