Application Development and Automation 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: 
Read only

INTERNAL TABLE

Former Member
0 Likes
484

I NEED A FIELD IN INTERNAL TABLE WITH STRING AND DATA OBJECT.

MY INTERNAL TABLE IS ITAB WITH C AS ITS FIELD.

I HAVE A DATA OBJECT B OF TYPE I.

I NEED TO ADD DATA INTO FIELD C OF INTERNAL TABLE WITH SOME TEXT AND THE VALUE IN THE DATA OBJECT B.

SOMETHIN LIKE THIS

C SHOULD CONTAIN : "CUSTOMER NO 10 DOES NOT EXIST".

HERE 10 IS THE NO STORED IN DATAOBJECT B WHICH CHANGES DYNAMICALLY.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
466

data: begin of itab occurs 0,

B type i,

C type string,

end of itab.

data: v_num(20) type c.

itab-b = 123.

clear v_num.

v_num = itab-b.

concatenate 'CUSTOMER NO' v_num 'DOES NOT EXIST' into itab-c separated by space.

append itab.

clear itab.

itab-b = 456.

clear v_num.

v_num = itab-b.

concatenate 'CUSTOMER NO' v_num 'DOES NOT EXIST' into itab-c separated by space.

append itab.

clear itab.

Message was edited by:

Velangini Showry Maria Kumar Bandanadham

3 REPLIES 3
Read only

Former Member
0 Likes
467

data: begin of itab occurs 0,

B type i,

C type string,

end of itab.

data: v_num(20) type c.

itab-b = 123.

clear v_num.

v_num = itab-b.

concatenate 'CUSTOMER NO' v_num 'DOES NOT EXIST' into itab-c separated by space.

append itab.

clear itab.

itab-b = 456.

clear v_num.

v_num = itab-b.

concatenate 'CUSTOMER NO' v_num 'DOES NOT EXIST' into itab-c separated by space.

append itab.

clear itab.

Message was edited by:

Velangini Showry Maria Kumar Bandanadham

Read only

Former Member
0 Likes
466

Hi,

Since you have to concatenate the data object 'B' and some text into the string field 'C' of the internal table, it's possible only if the integer value 'B' is moved to any string variable (Concatebation is performed only on string or character type fields).

For eg:

-


data: l_cust type string.

B =10.

l_cust = B.

Concatenate 'CUSTOMER NO' l_cust ' DOES NOT EXIST' into itab-c separated by space.

append itab.

Concatenate statement will return the text as 'CUSTOMER NO 10 DOES NOT EXIST'' into the field 'C' of the internal table.

Hope this helps..

Regards,

Dilli

Read only

Former Member
0 Likes
466

try something like this - here i am trying to use a FM for building the message text out of message number and message ID.


REPORT ZSKC_TEST3.

DATA : BEGIN OF ITAB OCCURS 0,
        KUNNR TYPE KUNNR,
        MSG   TYPE CHAR255,
       END   OF ITAB.

START-OF-SELECTION.

* Test data
  SELECT KUNNR UP TO 5 ROWS
  FROM    KNA1
  INTO    TABLE ITAB
  WHERE   KUNNR NE SPACE.

  CHECK SY-SUBRC EQ 0.

* Processing text for Customers USING message 132(B0).
  LOOP AT ITAB.
    CALL FUNCTION 'MESSAGE_TEXT_BUILD'
      EXPORTING
        MSGID                     = 'B0'
        MSGNR                     = '132'
        MSGV1                     = ITAB-KUNNR
      IMPORTING
        MESSAGE_TEXT_OUTPUT       = ITAB-MSG.

   MODIFY  ITAB TRANSPORTING MSG.
  ENDLOOP.

  BREAK-POINT.

The output is -

0000000001|Customer 0000000001 does not exist <

0000000006|Customer 0000000006 does not exist <

0000001179|Customer 0000001179 does not exist <

0000001700|Customer 0000001700 does not exist <

0000002200|Customer 0000002200 does not exist <

hope it solves ur problem.

Message was edited by:

SKC