‎2010 Oct 18 2:30 PM
Hi All,
I have a requirement where i have to convert table type element to String and then update it in the workflow container as workflow container can take type string or character of 255 or integer, ect
How do i convert Table type element to Char of 255? the data in the table is always a sentence or just a string.
Regards,
Lavanya
‎2010 Oct 18 3:25 PM
A simple MOVE or CONCATENATE operation will work from the source to the target...
‎2010 Oct 18 4:00 PM
It throws an error saying element can not be converted to a table type element.
Here i have my data in Ptex type tablet.
I have Ptext1(225) type C.
I am trying to move from ptext to Ptext1, it says " The type of "PTEXT" cannot be converted to the type of "PTEXT1".
Regards,
Lavanya.
‎2010 Oct 18 4:08 PM
I don't know what type 'tablet' is - what type is your PTEXT field? Give more info and you'll get a better answer .
‎2010 Oct 19 5:04 AM
DATA: lv_Begda1 TYPE BEGDA,
lv_ENDDA1 TYPE ENDDA,
PTEXT TYPE RP50M-TEXT1 OCCURS 0,
TX-KEY LIKE PSKEY.
if lv_tmart = 'J2'.
SELECT SINGLE
Begda Endda from PA0019
INTO (lv_Begda1 , lv_ENDDA1)
where pernr = lv_pernr AND tmart = 'J2' .
TX-KEY-PERNR = lv_pernr.
TX-KEY-INFTY = '0019'.
TX-KEY-SUBTY = 'J2'.
TX-KEY-ENDDA = lv_Begda1.
TX-KEY-BEGDA = lv_ENDDA1.
TX-KEY-SEQNR = '000'.
IMPORT ptext FROM DATABASE pcl1(tx) ID tx-key.
DATA: Ptext1(225) TYPE C.
Ptext1 = ptext .
Move 'Abs_Reason' TO itab_wf-element.
MOVE ptext1 to itab_wf-Value.
APPEND itab_wf.
Move 'Abs_Begda' TO itab_wf-element.
MOVE lv_Begda1 to itab_wf-Value.
APPEND itab_wf.
Move 'Abs_Endda' TO itab_wf-element.
MOVE lv_ENDDA1 to itab_wf-Value.
APPEND itab_wf.
This is my code. I am importing ptext from a cluster table and then move it to Ptext1.
‎2010 Oct 22 10:31 AM
Hi,
You can use the class CL_ABAP_CONTAINER_UTILITIES -->method FILL_CONTAINER_C to convert a structure to string.
The variables ptext and ptext1 are of different types. One is a structure/ internal table and the other is a CHAR.
So instead of using " ptext1 = ptext ", you must loop at each record in the internal table and concatenate all the fields in the record into ptext1.
Hope this solves.
Thanks,
Teja.
‎2010 Oct 22 10:42 AM
Hi.
Is it something like this that you are looking for
*&---------------------------------------------------------------------*
*& Form convert_table_to_string
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM convert_table_to_string .
DATA: str TYPE string,
len TYPE i,
tot_len TYPE i.
TYPES : BEGIN OF ty_text ,
tdformat TYPE tline-tdformat,
tdline TYPE tline-tdline,
END OF ty_text.
data: g_t_text TYPE STANDARD TABLE OF ty_text WITH HEADER LINE,
FIELD-SYMBOLS <fs1> TYPE ANY.
IF g_t_ekpo-ebeln IS NOT INITIAL.
CONCATENATE g_t_ekpo-ebeln g_t_ekpo-ebelp INTO g_ebeln. "CRQ94538-Capture text
SHIFT g_ebeln LEFT DELETING LEADING space.
PERFORM read_text USING g_ebeln g_t_text[].
IF g_t_text[] IS NOT INITIAL.
CLEAR: len,
tot_len,
str.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE g_t_text TO <fs1>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
DESCRIBE FIELD <fs1> LENGTH len IN CHARACTER MODE.
ADD len TO tot_len.
ENDDO.
CALL FUNCTION 'CONVERT_TABLE_TO_STRING'
EXPORTING
i_tabline_length = tot_len
IMPORTING
e_string = str
TABLES
it_table = g_t_text[].
IF sy-subrc = 0.
g_t_ekpo-text = str.
ENDIF.
ELSE.
CLEAR: g_t_ekpo-text,
tot_len,
len,
str. .
ENDIF.
ENDIF.
ENDFORM. " convert_table_to_string
Thanks,
Kiran.