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: 

Moving a string in a variable field.

Former Member
0 Kudos

I have defined:

Data: objtxt like solisti1 occurs 0 with header line.

I want to concatenate two words with like ten spaces in between and move it to obtxt. How cam I do that ?

For ex:

Usserid......................z998iis

But when I use concatenate even with spaces in between it concatnates the two words. I can I maintains spaces between these words when concatenating and moving in the field

Regards,

Rajesh.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is one way.

Data: objtxt like solisti1 occurs 0 with header line.

CONCATENATE 'Userid' '##########' 'z998iis' into objtxt.
replace '##########' in objtxt with space.

But you might want to also look into using HTML to format the output of your email. It would be easier than trying to line all this up. Here is an example of using HTML in your email body. In your case, you can use a <table> tag to set up some columns with the appropriate spacing.

report zrich_0002.

data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.


  mailtxt  = '<html>'.
  append mailtxt.


  mailtxt  = '<body>'.
  append mailtxt.

  mailtxt
   = '<a href="http:\\www.sap.com" target="_blank">SAP Hyperlink</a> '.
  append mailtxt.

  mailtxt  = '</body>'.
  append mailtxt.

  mailtxt  = '</html>'.
  append mailtxt.


  mailrec-receiver = 'putyourmailaddresshere'.
  mailrec-rec_type  = 'U'.
  append mailrec.

  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       exceptions
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5

            x_error                    = 6
            enqueue_error              = 7
            others                     = 8.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

Regards,

Rich Heilman

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

Try like this instead of the concatenate:


objtxt+0(20) = 'User ID'.
objtxt+20(12) = 'z998iis'.

Regards,

Naimesh Patel

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is one way.

Data: objtxt like solisti1 occurs 0 with header line.

CONCATENATE 'Userid' '##########' 'z998iis' into objtxt.
replace '##########' in objtxt with space.

But you might want to also look into using HTML to format the output of your email. It would be easier than trying to line all this up. Here is an example of using HTML in your email body. In your case, you can use a <table> tag to set up some columns with the appropriate spacing.

report zrich_0002.

data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.


  mailtxt  = '<html>'.
  append mailtxt.


  mailtxt  = '<body>'.
  append mailtxt.

  mailtxt
   = '<a href="http:\\www.sap.com" target="_blank">SAP Hyperlink</a> '.
  append mailtxt.

  mailtxt  = '</body>'.
  append mailtxt.

  mailtxt  = '</html>'.
  append mailtxt.


  mailrec-receiver = 'putyourmailaddresshere'.
  mailrec-rec_type  = 'U'.
  append mailrec.

  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       exceptions
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5

            x_error                    = 6
            enqueue_error              = 7
            others                     = 8.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

Regards,

Rich Heilman

former_member194669
Active Contributor
0 Kudos

Else try this way


types : begin of t1,
        field1(10) type c,
        field2(10) type c,
        field3(10) type c.
types : end of t1.

data  : wa_t1 type t1.

move 'User id' to wa_t1-field1.
move 'zxxxxxx' to wa_t1-field3.

move wa_t1 to objtxt.

naimesh_patel
Active Contributor
0 Kudos

As Rich, suggested you can use the HTML to display your data in the Table format.

Check my answer in this post for how to dispaly data in proper table format.

Regards,

Naimesh Patel

former_member194669
Active Contributor
0 Kudos

else try this way


data : field(30) type c.
concatenate 'test     '  'test1' into field respecting blanks.