09-01-2008 1:53 PM
Hi All,
I have a requirement where there is a string suppose
$self.qty = ( ( 3.1429 * dpcc_c * dpcc_c ) / 4 ) * hpcc_c if V_PCC = 'V_PCC_CIRC' , $self.qty = lpcc_r * bpcc_r * hpcc_r * n if v_PCC = 'V_PCC_RECT' , $self.qty = ( lpcc_t * bpcc_t * hpcc_t * n ) + ( h1pcc_t / 2 * ( lpcc_T + l1pcc_t )
In this string i want to divide it according to the ' ' marks so that the both starting and ending codes should be in the same line, and the maximum length of the line is 72 char, so need to divide is first on the basis of ' if no quotes found then split at 72 char.
need to check both the conditions single quotes and length in one line 72 and append in a table like the output in the table sholuld be like this.
$self.qty = ( ( 3.1429 * dpcc_c * dpcc_c ) / 4 ) * hpcc_c if V_PCC =
'V_PCC_CIRC' , $self.qty = lpcc_r * bpcc_r * hpcc_r * n if v_PCC =
'V_PCC_RECT' , $self.qty = ( lpcc_t * bpcc_t * hpcc_t * n )+ ( h1pcc_t
/ 2 * ( lpcc_T + l1pcc_t ).
Please suggest some solution.
Thanks
Mona
09-01-2008 2:12 PM
Hi,
Use SPLIT Command.
Example:
data:
w_data(72) type c 'ABAP is easy'.
Split w_data at ' ' into w_data1 w_data2 w_data3.
Regards,
Rama.
09-01-2008 2:18 PM
Hi Mona,
You can use the SPLIT command to split the text.
SPLIT dobj AT sep INTO
{ {result1 result2 ...} | {TABLE result_tab} }
[IN {BYTE|CHARACTER} MODE].
You can move the split string into the TABLE result tab.
Anand
09-02-2008 5:12 AM
Hi
I know to use split command but my problem is i want the quotes along with the string after splitting , but split command removes that and also i need to count 72 characters.
09-02-2008 6:17 AM
I know to use split command but my problem is i want the quotes along with the string after splitting , but split command removes that and also i need to count 72 characters.
You said After Split the string quotes are remove.can you not concatenate again only quotes after split?
09-02-2008 5:30 AM
Hi,
Check the function module: STRING_SPLIT_AT_POSITION
Regards,
Bhaskar
09-02-2008 5:49 AM
Dear Mona
Please let me know the correct string what you want to split
because what you mentioned text is not possible to post as string
your requirement is clear and it can be happen
please give us correct string and if you like describe us why you doing such a thing.
Regards
Nelson From Sri Lanka
09-02-2008 6:03 AM
hi Nelson,
This is the string which i need to append and its taking as a sting no poblem in that.
09-02-2008 5:42 AM
try this .........
FIND FIRST OCCURRENCE of ''' in section offset off of string.
" Search for the forst occurence of ' .
if off > 72 . " if first occurrence is after 72
off = 72 . " set the offset to 72
endif.
append string(off) to internal_table.
string = string + off .
hope it helps .......
09-02-2008 5:44 AM
You can use
FIND ALL OCCURRENCES OF substring IN string RESULTS result_tab.
This will give offset points of the substring in table result. Loop the table and use the offset to split ur string.
Regards
Sathar
09-02-2008 5:50 AM
One way to get this is to use two nested do loops.
The outer loop will split the main string at first single quote.
The inner loop will check lenghth of splitted portion and split it further if lenghth is more than 72.
regarding the lost single quote, you can pad it with concatenate after splitting.
Inside the inner loop you can populate a temp internal table. The final internal table can be built using temp internal table at the end of inner do loop. (temp internal table to be refreshed on end of each inner loop)
please provide proper exit points for both do loops.