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: 

Splitting up the data into various excel sheets

Former Member
0 Kudos

Hi ,

I have the following requirement. I need to split up the data present in an internal table into various excel sheets and need to send the same via email to a distribution list. For sending the email, I am using the FM"SO_NEW_DOCUMENT_SEND*".

How can i split up the data into the excel sheet....suppose i plan to have 500 entries in one excel sheet...how can i go about doing the same.

Please provide me with the approach of splitting the data into various excel sheets as well as various tab pages in the same excel sheet.

It wud be gr8 if i cud get a early response for the same

Thanks.

2 REPLIES 2

Former Member
0 Kudos

Hi Eshwar Salivati

Please see follow the below steps and see the below code. So that u can get an idea and can work on ur requirement.

Keep the entire attachement data in one internal table.

Build PACKING_LIST table parameters with number of lines,document size...etc (please see below code) details per each attachment. This should be populated one record per attachment. So that u can get as many attachments as you want.

DESCRIBE TABLE LT_OBJTXT LINES LV_TAB_LINES.

READ TABLE LT_OBJTXT INDEX LV_TAB_LINES.

LV_DOCDATA-DOC_SIZE = ( LV_TAB_LINES - 1 ) * 255 +

STRLEN( LT_OBJTXT ).

CLEAR LT_OBJPACK-TRANSF_BIN.

LT_OBJPACK-HEAD_START = 1.

LT_OBJPACK-HEAD_NUM = 0.

LT_OBJPACK-BODY_START = 1.

LT_OBJPACK-BODY_NUM = LV_TAB_LINES.

LT_OBJPACK-DOC_TYPE = 'RAW'.

APPEND LT_OBJPACK.

  • Populating packing list for XLS attachment one.

IF NOT LT_ATT_TAB[] IS INITIAL AND

NOT GV_ERR_REC IS INITIAL.

DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.

LV_TAB_LINES = LV_TAB_LINES - GV_SUC_REC.

READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.

LT_OBJPACK-DOC_SIZE =

( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).

LT_OBJPACK-TRANSF_BIN = 'X'.

LT_OBJPACK-HEAD_START = 1.

LT_OBJPACK-HEAD_NUM = 0.

LT_OBJPACK-BODY_START = 1.

LT_OBJPACK-BODY_NUM = LV_TAB_LINES.

LT_OBJPACK-DOC_TYPE = LC_XLS.

LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'.

LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME2(50).

APPEND LT_OBJPACK.

ENDIF. " IF NOT lt_att_tab[] IS ...

  • Populating packing list for XLS attachment two

IF NOT LT_ATT_TAB[] IS INITIAL AND

NOT GV_SUC_REC IS INITIAL.

CLEAR LT_OBJPACK.

DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.

LV_TAB_LINES = LV_TAB_LINES - GV_ERR_REC.

GV_ERR_REC = GV_ERR_REC + 1.

READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.

  • subrc check not required.

LT_OBJPACK-DOC_SIZE =

( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).

LT_OBJPACK-TRANSF_BIN = 'X'.

LT_OBJPACK-HEAD_START = GV_ERR_REC.

LT_OBJPACK-HEAD_NUM = 0.

LT_OBJPACK-BODY_START = GV_ERR_REC.

LT_OBJPACK-BODY_NUM = LV_TAB_LINES.

LT_OBJPACK-DOC_TYPE = LC_XLS.

LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'(009).

LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME(50).

APPEND LT_OBJPACK.

ENDIF. " IF NOT lt_att_tab[] IS ...

CLEAR: GV_ERR_REC,

GV_SUC_REC.

  • move email ID's to receivers list.

CLEAR LT_RECLIST.

MOVE:

GV_MAILID TO LT_RECLIST-RECEIVER,

GV_MAILID TO LT_RECLIST-REC_ID,

'U' TO LT_RECLIST-REC_TYPE,

C_TRUE TO LT_RECLIST-EXPRESS.

APPEND LT_RECLIST.

CLEAR LT_RECLIST.

SELECT YYVALUE INTO LT_RECLIST-RECEIVER

FROM YSPARAMVALUE

WHERE YYBUS_OWNER = 'AR'

AND YYKEY = GT_FINAL-ORIGIN.

LT_RECLIST-REC_ID = LT_RECLIST-RECEIVER.

LT_RECLIST-REC_TYPE = 'U'.

LT_RECLIST-EXPRESS = 'X'.

APPEND LT_RECLIST.

CLEAR LT_RECLIST.

ENDSELECT.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = LV_DOCDATA

PUT_IN_OUTBOX = C_TRUE

TABLES

PACKING_LIST = LT_OBJPACK

OBJECT_HEADER = LT_OBJHEAD

CONTENTS_BIN = LT_OBJBIN

CONTENTS_TXT = LT_OBJTXT

RECEIVERS = LT_RECLIST

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.

PERFORM SEND_MESSAGE USING C_BOTH

C_VERY_IMPORTANT

'E'

P_OBJ

'000'

'Email Send Error'(071)

SPACE

SPACE

SPACE.

ENDIF. " IF sy-subrc <> 0

Reward for useful answer.... Please get back if any problem

Former Member
0 Kudos