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

Problem with append table

Former Member
0 Likes
840

Hi,

i want to insert a line into a internal table ; the type of table is a type of table for example Z_MYSTRUCT. Z_MYSTRUCT is a type of line so to insert a new line into my table i can't do this :

data : l_new type Z_MYSTRUCT.

l_new-field1 = 'value'.

append l_new into mytable.

How can i do this ?

Regards

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
800


data: mytable type table of Z_MYSTRUCT.
data: l_new type Z_MYSTRUCT.

append l_new TO mytable.

REgards,

RIch HEilman

Read only

0 Likes
800

Thanks for prompt reply.

I have an requirement where in transaction MIGO. when user clicks on POST button, at that time the data should be e-mailed to the Vendor.

So for that i have created a Z implementation of BADI MB_MIGO_BADI.

Now in that i have written a Function Module name as Z_SENDMAIL.

where i have table paramater which is of type BCSY_TEXT which is again of LINE type of SOLI.

Now the data of MIGO is filled in table IT_MSEG which is paramter of Method POST_DOCUMENT of MB_MIGO_BADI.

So problem comes that how should i fill the data in my line type table of Function Module.

For your information i am sending you the FM.

FUNCTION Z_SENDMAIL.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(FROM) TYPE ADR6-SMTP_ADDR OPTIONAL

*" REFERENCE(TO) TYPE ADR6-SMTP_ADDR OPTIONAL

*" REFERENCE(SUBJECT) TYPE SO_OBJ_DES

*" REFERENCE(FLAG) TYPE CHAR1 OPTIONAL

*" EXPORTING

*" REFERENCE(RETURNCODE) TYPE SY-SUBRC

*" TABLES

*" IT_TEXT TYPE BCSY_TEXT

*" IT_EMAILS STRUCTURE SOMLRECI1 OPTIONAL

*"----


TYPES : BEGIN OF TS_REC,

RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,

END OF TS_REC.

DATA : IS_T1(255) TYPE C,

IT_REC TYPE TABLE OF TS_REC,

IS_REC TYPE TS_REC,

W_EMAIL TYPE ADR6-SMTP_ADDR,

W_TEXT TYPE BCSY_TEXT,

W_DOCUMENT TYPE REF TO CL_DOCUMENT_BCS,

W_SENDER TYPE REF TO IF_SENDER_BCS,

W_RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,

W_SENT_TO_ALL TYPE OS_BOOLEAN,

W_OREF TYPE REF TO CX_ROOT,

W_TEXT1 TYPE STRING,

W_SEND_REQUEST TYPE REF TO CL_BCS,

W_TABIX TYPE SY-TABIX.

CONSTANTS: C_TYPE TYPE SO_OBJ_TP VALUE 'RAW',

C_LENGTH TYPE SO_OBJ_LEN VALUE '12',

C_X TYPE C VALUE 'X'.

FROM = abc@yahoo.com'.

TRY.

  • create persistent send request

W_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).

LOOP AT IT_TEXT INTO IS_T1.

APPEND IS_T1 TO W_TEXT.

CLEAR IS_T1.

ENDLOOP.

W_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(

I_TYPE = C_TYPE

I_TEXT = W_TEXT

I_LENGTH = C_LENGTH

I_SUBJECT = SUBJECT ).

  • add document to send request

CALL METHOD W_SEND_REQUEST->SET_DOCUMENT( W_DOCUMENT ).

  • set sender

  • note: this is necessary only if you want to set the sender

  • different from actual user (SY-UNAME). Otherwise sender is

  • set automatically with actual user.

  • sender = cl_sapuser_bcs=>create( sy-uname ).

W_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( FROM

).

CALL METHOD W_SEND_REQUEST->SET_SENDER

EXPORTING

I_SENDER = W_SENDER.

  • add recipient (e-mail address)

  • create recipient - please replace e-mail address !!!

IF TO IS NOT INITIAL .

W_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(

TO ).

CALL METHOD W_SEND_REQUEST->ADD_RECIPIENT

EXPORTING

I_RECIPIENT = W_RECIPIENT

  • i_copy = c_x

I_EXPRESS = C_X.

**********************************************

W_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).

CALL METHOD W_SEND_REQUEST->SEND(

EXPORTING

I_WITH_ERROR_SCREEN = C_X

RECEIVING

RESULT = W_SENT_TO_ALL ).

COMMIT WORK.

ENDIF.

CATCH CX_SY_ARITHMETIC_ERROR INTO W_OREF.

RETURNCODE = 4.

W_TEXT1 = W_OREF->GET_TEXT( ).

CATCH CX_ROOT INTO W_OREF.

RETURNCODE = 4.

W_TEXT1 = W_OREF->GET_TEXT( ).

ENDTRY.

LOOP AT IT_EMAILS.

TRY.

CLEAR W_EMAIL.

W_EMAIL = IT_EMAILS-RECEIVER.

W_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(

W_EMAIL ).

IS_REC-RECIPIENT = W_RECIPIENT.

APPEND IS_REC TO IT_REC.

CATCH CX_ADDRESS_BCS.

RETURNCODE = 4.

ENDTRY.

ENDLOOP.

LOOP AT IT_REC INTO IS_REC.

TRY.

W_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).

W_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(

I_TYPE = C_TYPE

I_TEXT = W_TEXT

I_LENGTH = C_LENGTH

I_SUBJECT = SUBJECT ).

  • add document to send request

CALL METHOD W_SEND_REQUEST->SET_DOCUMENT( W_DOCUMENT ).

  • set sender

  • note: this is necessary only if you want to set the sender

  • different from actual user (SY-UNAME). Otherwise sender is

  • set automatically with actual user.

  • sender = cl_sapuser_bcs=>create( sy-uname ).

W_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(

FROM ).

CALL METHOD W_SEND_REQUEST->SET_SENDER

EXPORTING

I_SENDER = W_SENDER.

CALL METHOD W_SEND_REQUEST->ADD_RECIPIENT

EXPORTING

I_RECIPIENT = IS_REC-RECIPIENT

I_EXPRESS = C_X.

W_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).

CALL METHOD W_SEND_REQUEST->SEND(

EXPORTING

I_WITH_ERROR_SCREEN = C_X

RECEIVING

RESULT = W_SENT_TO_ALL ).

  • COMMIT WORK.

CATCH CX_SY_ARITHMETIC_ERROR INTO W_OREF.

RETURNCODE = 4.

W_TEXT1 = W_OREF->GET_TEXT( ).

CATCH CX_ROOT INTO W_OREF.

RETURNCODE = 4.

W_TEXT1 = W_OREF->GET_TEXT( ).

ENDTRY.

ENDLOOP.

IF FLAG = 'X'.

IF TO IS NOT INITIAL.

IT_EMAILS-RECEIVER = TO.

APPEND IT_EMAILS TO IT_EMAILS.

ENDIF.

ENDIF.

ENDFUNCTION.

So pls help me out asap its very Urgent.......

Regards,

DS

Read only

Former Member
0 Likes
800

Is this what you are looking for?

DATA: L_NEW TYPE STANDARD TABLE OF Z_MYSTRUCT WITH HEADER LINE.

L_NEW-FIELD1 = 'VALUE'.

APPEND L_NEW.

MYTABLE[] = L_NEW[].

Provided mytable and l_new has same structure.

Thanks,

Santosh

Read only

Former Member
0 Likes
800

Hi,

I think this is the procedure for hat u have asked.

data: new type standard table of Z_mystruct with header line.

new-field1 = 'value'.

append new.

mytable[] = new[].

Reward points if it is helpfull for you.

Read only

Former Member
0 Likes
800

data : l_new type Z_MYSTRUCT.

l_new-field1 = 'value'.

append l_new to mytable.

Read only

Former Member
0 Likes
800

Hai

Eric,

Try this...

data: mytable like z_mystruct occurs 0." with header line.

data: i_new type z_mystruct .

clear i_new

i_new-fieldname = 'value'.

append i_new to mytable.

Hope it helps!!

Regards,

Swetha

Read only

Former Member
0 Likes
800

Hai

Eric,

Try this...

data: mytable like z_mystruct occurs 0.

data: i_new type z_mystruct .

clear i_new

i_new-fieldname = 'value'.

append i_new to mytable.

Hope it helps!!

Regards,

Swetha