Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert workarea to CHAR?

Former Member
0 Kudos

Hi,

Is there an FM to convert workare into CHAR?


LOOP AT it_table into wa_table
  
  Convert wa_table to char. ???????????????????????????

  CONCATENATE 
  wa_field1
  wa_field2
  wa_field3
  ets.............................
  into h_row
  SEPERATED BY ';'
 
  APPEND h_row TO it_billit_down.
 
ENDLOOP.

PERFORM GUI_DOWNLOAD.

Adibo..:)

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hey reward points for help ful answers yaaarrrrrrrrr.......

10 REPLIES 10

varma_narayana
Active Contributor
0 Kudos

Hi Adibo..

There is no FM for this..

Declare Character fields and Move the Workarea fields into these character fields.

LOOP AT it_table into wa_table

Move wa-field1 to V_char1.

Move wa-field2 to V_char2.

CONCATENATE

V_char1

v_char2

etc.............................

into h_row

SEPERATED BY ';'

APPEND h_row TO it_billit_down.

ENDLOOP.

<b>reward if Helpful</b>

Former Member
0 Kudos

Hi Adibo,

Check this function module <b>C147_WORKAREA_TO_CHARFIELD</b> which converts workarea to character field.

Thanks,

Vinay

0 Kudos

Hi Vinaykumar G,

SE37 --> C147_WORKAREA_TO_CHARFIELD does not exist?

Adibo.

Former Member
0 Kudos

hey a simple move statement work here right.....declare u char as a variable ...then move u r workarea to char variable......(if u r workarea length and char length is same ....other wise declare u r field as string)

i hope this would be helpful........

move wa_field to v_char.

reward points if helpful....

gopi_narendra
Active Contributor
0 Kudos

follow this example and do it accordingly

DATA : BEGIN OF it_tab OCCURS 0,
         string TYPE string,
       END OF it_tab.
DATA : it_final TYPE TABLE OF ekko WITH HEADER LINE.
DATA : l_string TYPE string.

LOOP AT it_final.
  CONCATENATE it_final-ebeln
              it_final-bukrs
              it_final-bstyp
              INTO l_string SEPARATED BY ';'.
  MOVE l_string TO it_tab-string.
  APPEND it_tab.
  CLEAR : it_final.
ENDLOOP.

Regards

Gopi

Former Member
0 Kudos

hI

YES

THERE IS ONE FM FOR THIS

<b>C147_WORKAREA_TO_CHARFIELD</b>

REWARD IF USEFULL

0 Kudos

HI

<b>IMPORT</b>

I_WORKAREA Feldleiste

<b>EXPORT</b>

E_CHARFIELD TYPE C Zeichenfolge

<b>SOURCE CODE</b>

FUNCTION C147_WORKAREA_TO_CHARFIELD.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" REFERENCE(I_WORKAREA)

*" EXPORTING

*" VALUE(E_CHARFIELD) TYPE C

*"----


  • Local data -------------------------------------------------------

DATA: L_COMP_REF TYPE REF TO DATA,

L_INDEX LIKE SY-INDEX,

L_COMP_LENGTH LIKE SY-FDPOS,

L_TYPE(1) TYPE C,

L_OFFSET LIKE SY-FDPOS.

FIELD-SYMBOLS: <L_COMP> TYPE ANY,

<L_COMP_AS_CHAR> TYPE C.

  • Function body ----------------------------------------------------

  • convert every component of the given work-area into characters

  • and concatenate them into the result-field

CLEAR E_CHARFIELD.

L_OFFSET = 0.

DO.

  • get the current component

L_INDEX = SY-INDEX.

ASSIGN COMPONENT L_INDEX OF STRUCTURE I_WORKAREA TO <L_COMP>.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

  • create a character-field at run-time, that has the same length,

  • than the current component, and move the component's value to it

DESCRIBE FIELD <L_COMP>

TYPE L_TYPE

OUTPUT-LENGTH L_COMP_LENGTH.

IF L_TYPE CA 'CNDT'. "#EC NOTEXT

DESCRIBE FIELD <L_COMP>

LENGTH L_COMP_LENGTH

IN CHARACTER MODE.

ELSE.

TRY.

CREATE DATA L_COMP_REF TYPE C LENGTH L_COMP_LENGTH.

CATCH CX_ROOT.

EXIT.

ENDTRY.

IF L_COMP_REF IS BOUND.

ASSIGN L_COMP_REF->* TO <L_COMP_AS_CHAR>.

ELSE.

EXIT.

ENDIF.

IF <L_COMP_AS_CHAR> IS ASSIGNED.

<L_COMP_AS_CHAR> = <L_COMP>. "type-casting

ELSE.

EXIT.

ENDIF.

ENDIF.

  • concatenate the created character-field into the result-field

IF L_TYPE CA 'CNDT'. "#EC NOTEXT

E_CHARFIELD+L_OFFSET(L_COMP_LENGTH) = <L_COMP>.

ELSE.

E_CHARFIELD+L_OFFSET(L_COMP_LENGTH) = <L_COMP_AS_CHAR>.

ENDIF.

ADD L_COMP_LENGTH TO L_OFFSET.

ENDDO.

ENDFUNCTION.

AVAILABLE IN sap

Former Member
0 Kudos

Txn all !!

The client is on 4.6C so I can't use FM.

I wil have to solve this with MOVE or WRITE!

Adibo.

Former Member
0 Kudos

hey reward points for help ful answers yaaarrrrrrrrr.......

Former Member
0 Kudos

use the FM

c147_workarea_to_charfield