Internal Table output in customer format ; write statement
Hello All,
I need help in printing the O/P.
Currently the program is displaying ALV.
However I need the O/P to be displayed like.
FIELDANAME1;FIELDNAME2;FIELDNAME3;....FNZ.
VALUE1;VALUE2;VALUE3....VZ.
Code is below - Dynamically it will show the table contents
according to the tabel name.
*& Report YREN_FIELDSDISPLAY
REPORT YREN_FIELDSDISPLAY.
FIELD-SYMBOLS:
<f_tab1> TYPE STANDARD TABLE.
PARAMETERS:
p_tname TYPE tabname16 OBLIGATORY, " DEFAULT 'MARA' ,
p_rows(5) TYPE c DEFAULT '200'.
CLASS lcl_dynamic DEFINITION
CLASS lcl_dynamic DEFINITION CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS:
check_selection
EXCEPTIONS invalid_table,
main
EXCEPTIONS no_data_found,
display.
PRIVATE SECTION.
TYPE-POOLS: abap.
CLASS-DATA: tab TYPE REF TO cl_abap_structdescr,
wa_tab TYPE REF TO cl_abap_structdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
i_tab TYPE REF TO cl_abap_tabledescr,
i_table TYPE REF TO data.
ENDCLASS. "lcl_dynamic DEFINITION
CLASS lcl_dynamic IMPLEMENTATION
CLASS lcl_dynamic IMPLEMENTATION.
METHOD check_selection.
SELECT COUNT( * )
FROM dd02l
WHERE tabname = p_tname
AND as4local = 'A'
AND tabclass = 'TRANSP'.
IF sy-subrc = 0.
RAISE invalid_table.
ENDIF.
ENDMETHOD. "check_selection
METHOD main.
tab ?= cl_abap_typedescr=>describe_by_name( p_tname ).
comp_tab = tab->get_components( ).
wa_tab = cl_abap_structdescr=>create( comp_tab ).
i_tab = cl_abap_tabledescr=>create( wa_tab ).
CREATE DATA i_table TYPE HANDLE i_tab.
ASSIGN i_table->* TO <f_tab1>.
IF p_rows IS INITIAL.
p_rows = '50000'.
ENDIF.
*Get data
SELECT * FROM (p_tname)
INTO TABLE <f_tab1>
UP TO p_rows ROWS.
IF sy-subrc EQ 0.
RAISE no_data_found.
ENDIF.
ENDMETHOD. "main
METHOD display.
SET TITLEBAR sy-title
OF PROGRAM sy-cprog
WITH 'Display table:' p_tname.
DATA:
l_gr_alv TYPE REF TO cl_salv_table,
l_gr_functions TYPE REF TO cl_salv_functions.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = l_gr_alv
CHANGING
t_table = <f_tab1>.
CATCH cx_salv_msg . "#EC NO_HANDLER
ENDTRY.
l_gr_functions = l_gr_alv->get_functions( ).
l_gr_functions->set_all( abap_true ).
l_gr_alv->display( ).
ENDMETHOD. "display
ENDCLASS. "lcl_dynamic IMPLEMENTATION
AT SELECTION-SCREEN.
CALL METHOD lcl_dynamic=>check_selection
EXCEPTIONS
invalid_table = 1.
IF sy-subrc EQ 0.
MESSAGE e001(00) WITH
p_tname ' is not a Transparant Table'.
ENDIF.
START-OF-SELECTION.
CALL METHOD lcl_dynamic=>main
EXCEPTIONS
no_data_found = 1.
IF sy-subrc EQ 0.
MESSAGE i001(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
END-OF-SELECTION.
CALL METHOD lcl_dynamic=>display.
Thanks,
Varun.
hi varun,
amandep is correct ...use REUSE_ALV_GRID_DISPLAY .If still you have problem in formatting then go through this code used for ALV display.
*& Report ZYOGALVEX1
REPORT ZYOGALVEX1.
type-pools: slis.
tables: zyogstudent,t001.
data: itab like zyogstudent occurs 0 with header line.
data: begin of jtab occurs 0,
bukrs like t001-bukrs,
butxt like t001-butxt,
ort01 like t001-ort01,
stceg like t001-stceg,
end of jtab.
data: field_cat type slis_t_fieldcat_alv,
xlayout type slis_layout_alv,
i_sort type slis_t_sortinfo_alv.
start-of-selection.
perform get_data.
perform dis_lay.
perform dis_sort.
perform display.
*& Form get_data
text
--> p1 text
<-- p2 text
form get_data .
select * from zyogstudent into table itab.
select bukrs ort01 stceg butxt from t001 into corresponding fields of table jtab.
perform field_init using field_cat.
endform. " get_data
*& Form dis_lay
text
--> p1 text
<-- p2 text
form dis_lay .
xlayout-zebra = 'X'.
xlayout-no_keyfix = 'X'.
xlayout-flexible_key = 'X'.
xlayout-colwidth_optimize = 'skip'.
xlayout-header_text = 'this is using header text'.
endform. " dis_lay
*& Form dis_sort
text
--> p1 text
<-- p2 text
form dis_sort .
data l_sort type slis_sortinfo_alv.
l_sort-fieldname = 'ZNAME'.
l_sort-tabname = 'ZYOGSTUDENT'.
l_sort-spos = 1.
l_sort-up = 'X'.
append l_sort to i_sort.
endform. " dis_sort
*& Form field_init
text
-->P_FIELD_CAT text
form field_init using p_field_cat.
data wa_cat type slis_fieldcat_alv.
wa_cat-fieldname = 'ZNAME'.
wa_cat-tabname = 'zyogstudent'.
wa_cat-outputlen = 25.
wa_cat-seltext_m = 'ZNAME'.
wa_cat-just = 'L'.
append wa_cat to field_cat.
wa_cat-fieldname = 'ZCLASS'.
wa_cat-tabname = 'zyogstudent'.
wa_cat-outputlen = 25.
wa_cat-seltext_m = 'ZCLASS'.
wa_cat-just = 'C'.
append wa_cat to field_cat.
wa_cat-fieldname = 'ZFEES'.
wa_cat-tabname = 'zyogstudent'.
wa_cat-outputlen = 25.
wa_cat-seltext_m = 'ZFEES'.
wa_cat-just = 'C'.
append wa_cat to field_cat.
wa_cat-fieldname = 'ZADD'.
wa_cat-tabname = 'zyogstudent'.
wa_cat-outputlen = 25.
wa_cat-seltext_m = 'ZADD'.
wa_cat-just = 'R'.
append wa_cat to field_cat.
endform. " field_init
*& Form display
text
--> p1 text
<-- p2 text
form display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'sy-repid'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_STRUCTURE_NAME = itab
I_GRID_TITLE = 'This is grid title'
IS_LAYOUT = xlayout
IT_FIELDCAT = FIELD_CAT
IT_SORT = i_sort
I_DEFAULT = 'X'
I_SAVE = ' '
IT_EVENTS =
TABLES
t_outtab = itab.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " display
Similar Messages
-
Convert internal table output to pdf format
Hi all,
my query is given below.
<removed by moderator>
i need to convert internal table output to Pdf. format
the Pdf file generating.
when i am opening the pdf. file shows error like there was an error opening this document . this file cannot be opened because it has no pages.
please help me.
thanks in advance.
Regards,
Karthikeyan Krishan
Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters each to preserve formatting.
Edited by: Thomas Zloch on Mar 30, 2011 12:57 PMHi,
Check this link where I send data in RAW format as attachment using cl_bcs.
Open PDF File stored in AL11 and send by email using CL_BCS.
Regards,
Ernesto -
How to display output without fieldnames in write statements
hi,
can any one tell how to get output with all fields values of a table without writing fieldnames in write statement.
giv proper code for this task.Thaks in advance.hiii
if you want to write just values then you can use write statement only ..no need to do anything else.simply write as follows
LOOP AT t_customer INTO fs_customer.
WRITE:/ fs_customer-customer_no,
fs_customer-customer_name,
fs_customer-customer_amount.
ENDLOOP
reward if useful
thx
twinkal -
Conversion of internal table into excel file format &put it on app server
Hi,
My requirement is to convert the internal table into excel file format and I have to store it on application server so that administrator can send the file thr e-mail attachment.
So, please let me know how to convert the records of internal table and store it on application server in Excel file format.
TIA,
NitinHi,
Use FM GUI_DOWNLOAD to download the data from inernal table to excel sheet.
Then Using tcode CG3Z u can transfer file to application server.
*& Form sub_download
text
--> p1 text
<-- p2 text
FORM sub_download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = p_path
filetype = 'ASC'
APPEND = ' '
write_field_separator = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_final
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " sub_download
Otherwise use OPEN DATASET and TRANSFER statement to download data from internal table to direct application server
Regards,
Prashant -
Download internal table data in excel format
Hi ,
i have a requirement where i need to download the internal table data in excel format .. I tried using the FM SAP_CONVERT_TO_XLS_FORMAT but this downloads to excel sheet same as .txt file foemat without columns ... i need to have the data in excel sheet with column heading and separated by each coulmn which should be similar as a general sheet with column names and the respective data in the columns . Appreciate any inputs .
Thanks,
Latha.Hi,
you can this in Debugging mode,
say,once you got entire data into ITAB
salect the TABLE option and provide the table name
now on the top most you can see excel icon,you click
on that,now system will prompts you for to the file to be saved.
Regards,
Vijaya. -
How to convert internal table data to PDF format
HI,
I have an internal table data having one field with 255 chars. length.I want to send that intenal table data as attachemnt with external mail. i am thinking of converting that data into PDF format and use the FM to send the mail. How to convert internal table data to PDF format.
KishoreIn which format is your data in the internal table currently. Is it returned by a smartform/script or its just data fetched from some database table into an internal table. Since its obvious that the data should appear in the PDF with some Layout, you should be using smartform to format the data properly. See the Link
Smartform to PDF to EMAIL
This shows convertion of smartform to pdf and send it through email
Regards,
Abhishek -
Getting data into internal table as per our format
Hi friends plz go through my requirement and provide me a solution for it.
data :
wa_t343j type t343j.
start-of-selection.
select single *
into wa_t343j
from t343j
WHERE lgnum = 'XYZ' and
lgtyp = 'ABC'.
In the work area wa_t343j iam getting the following values
lgnum lgtyp ste01 ste02 ste03 st304 ste05 ste06 ste07 ste08
XYZ ABC 5 3 1 2 4
now my requiremnt is i want this value in a sepearte internal table in the below format.
data :
begin of it_temp,
index type i,
field type ltap-vlpla,
value type ltap-vlpla,
end of it_temp.
Internal table it_temp
Index field value
1 LGNUM XYZ
2 LGTYP ABC
3 STE01 5
4 STE02
9 STE07 4
10 STE08
i need those values in this format.
Thanks in advance,
Regards,
Kumar.
Edited by: satish abap on Aug 12, 2008 8:59 PMDo something like this..
Types : begin of tt_temp,
index type i,
field type char30,
value type char30,
end of tt_temp.
data: it_temp type table of tt_temp.
data: wa_temp like line of it_temp.
data: it_fieldlist type table of rstrucinfo.
data: wa_fieldlist like line of it_fieldlist.
data: lv_repid type sy-repid.
FIELD-SYMBOLS: <fs> type any.
lv_repid = sy-repid.
call function 'GET_COMPONENT_LIST'
exporting
program = lv_repid
fieldname = 'wa_t343j'
tables
components = it_fieldlist.
Loop at it_fieldlist into wa_fieldlist.
clear wa_temp.
wa_temp-index = sy-tabix.
wa_temp-field = wa_fieldlist-compname.
assign COMPONENT wa_temp-field of STRUCTURE wa_t343j to <fs>.
wa_temp-value = <fs>.
append wa_temp to it_temp.
endloop.
Regards,
Rich Heilman -
How to convert internal table data into excel format?
Hi all,
I want to convert internal table data in excel format and then
send it as email attachment in workflow.
Please tell me how do i perform this.
Regards,
Arpita.Hi Arpita,
Try this sample code::
Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = 'your receiver mail id'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'EXL'
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.
Hope it will help you.
Regards,
NIkita -
Need a POP-UP which can display internal table data in ALV format
HI All,
I need to display INTERNAL TABLE values through a POP-UP. Only condition is that the window with the internal table data should be in ALV format and not in TEXT only format.
To clarify, I used FM 'POPUP_WITH_TABLE_DISPLAY_OK' and 'POPUP_WITH_TABLE_DISPLAY', but both display the data in TEXT format and there is no provision to put the FIELD names there. Everthing needs to be put into internal table and it displays it in text format.
So I want a FM where I can display internal tabel data in ALV format( same format that would appear if you creata search help for a filed and output window would have all the ALV features like SORT buttons etc.
Hope there is some FM to achieve this ALV format data thing.
Thanks in advance for all your help.
Regards
FX3check this
REPORT y_demo_alv_3.
TYPE-POOLS: slis.
DATA: BEGIN OF i_outtab OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: w_chk TYPE c. "For multiple selection
DATA: END OF i_outtab.
* I_OUTTAB TYPE SFLIGHT OCCURS 0,
DATA: i_private TYPE slis_data_caller_exit,
i_selfield TYPE slis_selfield,
W_exit(1) TYPE c.
PARAMETERS: p_title TYPE sy-title.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE i_outtab.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = p_title
i_selection = 'X'
i_zebra = 'X'
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
i_checkbox_fieldname = 'W_CHK'
* I_LINEMARK_FIELDNAME =
* I_SCROLL_TO_SEL_LINE = 'X'
i_tabname = 'I_OUTTAB'
i_structure_name = 'SFLIGHT'
* IT_FIELDCAT =
* IT_EXCLUDING =
* I_CALLBACK_PROGRAM =
* I_CALLBACK_USER_COMMAND =
* IS_PRIVATE = I_PRIVATE
IMPORTING
es_selfield = i_selfield
e_exit = w_exit
TABLES
t_outtab = i_outtab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE i000(0k) WITH sy-subrc.
ENDIF.
*****the internal table is modified with a cross sign for marking the
***rows selected
LOOP AT i_outtab WHERE w_chk = 'X'.
WRITE: / i_outtab-carrid, i_outtab-price.
ENDLOOP. -
Error while creating a dynamic internal table refers to custom field
Hi all,
I am getting the exception TYPE_NOT_FOUND when I try to create a dynamic internal table using:-
DATA: gr_desc TYPE REF TO cl_abap_typedescr.
gr_desc = cl_abap_typedescr=>describe_by_name( p_field ).
The field p_field is a Z-field inside a DB table, (e.g. a user added field in MARA). The statement fails at that point and gives a runtime exception. Any suggestions to how I may solve this problem? Or any alternatives for the same? I guess we face this issue for all custom fields..has SAP released a note for this??
Thanks..that's just the wrong method, you should use DESCRIBE_BY_DATA
gr_desc = cl_abap_typedescr=>describe_by_data( p_field ).
Note: DESCRIBE_BY_NAME is to be used for referencing a DDIC type by its name. Example:
gr_desc = cl_abap_typedescr=>describe_by_name( 'MARA-ZZFIELD' ). -
Convert internal table data to pdf format and send mail to Users
Hi all ,
I want to convert the data available in internal table to pdf format and then send it to mail .
Please tell me wht are the fn modules available to convert the data from internal table to pdf and then send it mail .
regards
santosh .Hi Santosh
Sending mail with attachment report in Background
Content Author: Fernando Faian
I have read the hint about "Sending mail with attachment report".
It's great, but how can I make this function work in background??
I had that needed last year too. See attachment a function group with two functions. The second one has that functionality to send email or fax (SAP office) with attachment objects in background job using SO_ATTACHMENT_INSERT function.
Pay attention because its working with output list from spool converted to pdf.
=================================================================================
z_send_email_fax_global
FUNCTION-POOL z_gfaian_mail_fax. "MESSAGE-ID ..
WORK TABLE AREAS
TABLES: tsp01.
INTERNAL TABLES
DATA: lt_rec_tab LIKE STANDARD TABLE OF soos1 WITH HEADER LINE,
lt_note_text LIKE STANDARD TABLE OF soli WITH HEADER LINE,
lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE.
DATA: lt_objcont LIKE STANDARD TABLE OF soli WITH HEADER LINE,
lt_objhead LIKE STANDARD TABLE OF soli WITH HEADER LINE.
DATA: pdf_format LIKE STANDARD TABLE OF tline WITH HEADER LINE.
TYPES: BEGIN OF y_files,
file(60) TYPE c,
END OF y_files.
DATA: lt_files TYPE STANDARD TABLE OF y_files WITH HEADER LINE.
DATA: l_objcont LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: l_objhead LIKE soli OCCURS 0 WITH HEADER LINE.
STRUCTURES
DATA: folder_id LIKE soodk,
object_id LIKE soodk,
link_folder_id LIKE soodk,
g_document LIKE sood4,
g_header_data LIKE sood2,
g_folmem_data LIKE sofm2,
g_header_data LIKE sood2,
g_receive_data LIKE soos6,
g_ref_document LIKE sood4,
g_new_parent LIKE soodk,
l_folder_id LIKE sofdk,
v_email(50).
DATA: hd_dat like sood1.
VARIABLES
DATA: client LIKE tst01-dclient,
name LIKE tst01-dname,
objtype LIKE rststype-type,
type LIKE rststype-type.
DATA: numbytes TYPE i,
arc_idx LIKE toa_dara,
pdfspoolid LIKE tsp01-rqident,
jobname LIKE tbtcjob-jobname,
jobcount LIKE tbtcjob-jobcount,
is_otf.
DATA: outbox_flag LIKE sonv-flag VALUE 'X',
store_flag LIKE sonv-flag,
delete_flag LIKE sonv-flag,
owner LIKE soud-usrnam,
on LIKE sonv-flag VALUE 'X',
sent_to_all LIKE sonv-flag,
g_authority LIKE sofa-usracc,
w_objdes LIKE sood4-objdes.
DATA: c_file LIKE rlgrap-filename,
n_spool(6) TYPE n.
DATA: cancel.
DATA: desired_type LIKE sood-objtp,
real_type LIKE sood-objtp,
attach_type LIKE sood-objtp,
otf LIKE sood-objtp VALUE 'OTF', " SAPscript Ausgabeformat
ali LIKE sood-objtp VALUE 'ALI'. " ABAP lists
CONSTANTS
CONSTANTS: ou_fol LIKE sofh-folrg VALUE 'O',
c_objtp LIKE g_document-objtp VALUE 'RAW',
c_file_ext LIKE g_document-file_ext VALUE 'TXT'.
=================================================================================
z_send_email_fax2
FUNCTION z_faian_mail_fax2.
""Interface local:
*" IMPORTING
*" REFERENCE(SRC_SPOOLID) LIKE TSP01-RQIDENT
*" REFERENCE(FAX_MAIL_NUMBER) TYPE SO_NAME
*" REFERENCE(HEADER_MAIL) TYPE SO_OBJ_DES
*" REFERENCE(OBJECT_TYPE) TYPE SO_ESCAPE
*" TABLES
*" LT_BODY_EMAIL STRUCTURE SOLI
*" EXCEPTIONS
*" ERR_NO_ABAP_SPOOLJOB
Fist part: Verify if the spool really exists
SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
IF sy-subrc NE 0.
RAISE err_no_abap_spooljob. "doesn't exist
ELSE.
client = tsp01-rqclient.
name = tsp01-rqo1name.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = client
name = name
part = 1
IMPORTING
type = type
objtype = objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4
OTHERS = 5.
IF objtype(3) = 'OTF'.
desired_type = otf.
ELSE.
desired_type = ali.
ENDIF.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = src_spoolid
desired_type = desired_type
IMPORTING
real_type = real_type
TABLES
buffer = l_objcont
EXCEPTIONS
no_such_job = 14
type_no_match = 94
job_contains_no_data = 54
no_permission = 21
can_not_access = 21
read_error = 54.
IF sy-subrc EQ 0.
attach_type = real_type.
ENDIF.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
owner = sy-uname
region = ou_fol
IMPORTING
folder_id = l_folder_id
EXCEPTIONS
OTHERS = 5.
fill out informations about the header of the email
CLEAR: g_document.
g_document-foltp = l_folder_id-foltp.
g_document-folyr = l_folder_id-folyr.
g_document-folno = l_folder_id-folno.
g_document-objtp = c_objtp.
g_document-objdes = header_mail.
g_document-file_ext = c_file_ext.
g_header_data-objdes = header_mail.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'SAVE'
office_user = sy-uname
IMPORTING
authority = g_authority
TABLES
objcont = lt_body_email
attachments = lt_attachments
CHANGING
document = g_document
header_data = g_header_data
EXCEPTIONS
OTHERS = 1.
folder_id-objtp = l_folder_id-foltp.
folder_id-objyr = l_folder_id-folyr.
folder_id-objno = l_folder_id-folno.
object_id-objtp = c_objtp.
object_id-objyr = g_document-objyr.
object_id-objno = g_document-objno.
link_folder_id-objtp = l_folder_id-foltp.
link_folder_id-objyr = l_folder_id-folyr.
link_folder_id-objno = l_folder_id-folno.
REFRESH lt_rec_tab.
CLEAR lt_rec_tab.
lt_rec_tab-sel = 'X'.
lt_rec_tab-recesc = object_type. "This field for FAX/MAIL
lt_rec_tab-recnam = 'U-'.
lt_rec_tab-deliver = 'X'.
lt_rec_tab-not_deli = 'X'.
lt_rec_tab-read = 'X'.
lt_rec_tab-mailstatus = 'E'.
lt_rec_tab-adr_name = fax_mail_number.
lt_rec_tab-sortfield = fax_mail_number.
lt_rec_tab-recextnam = fax_mail_number.
lt_rec_tab-sortclass = '5'.
APPEND lt_rec_tab.
lt_rec_tab-recextnam = fax_mail_number.
lt_rec_tab-recesc = object_type.
lt_rec_tab-sndart = 'INT'.
lt_rec_tab-sndpri = 1.
APPEND lt_rec_tab.
lt_files-file = c_file.
APPEND lt_files.
begin of insertion by faianf01
hd_dat-objdes = header_mail.
CALL FUNCTION 'SO_ATTACHMENT_INSERT'
EXPORTING
object_id = object_id
attach_type = attach_type
object_hd_change = hd_dat
owner = sy-uname
TABLES
objcont = l_objcont
objhead = l_objhead
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
object_type_not_exist = 17
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
x_error = 1000.
IF sy-subrc > 0.
ENDIF.
end of insertion by faianf01
send email from SAPOFFICE
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
folder_id = folder_id
object_id = object_id
outbox_flag = outbox_flag
link_folder_id = link_folder_id
owner = sy-uname
check_send_authority = 'X'
TABLES
receivers = lt_rec_tab
note_text = lt_note_text
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
component_not_available = 1
folder_no_authorization = 5
folder_not_exist = 6
forwarder_not_exist = 8
object_no_authorization = 13
object_not_exist = 14
object_not_sent = 15
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
too_much_receivers = 73
user_not_exist = 35.
ENDIF.
ENDFUNCTION.
=================================================================================
z_send_email_fax
FUNCTION ZCBFS_SEND_MAIL.
""Interface local:
*" IMPORTING
*" REFERENCE(SRC_SPOOLID) LIKE TSP01-RQIDENT
*" REFERENCE(HEADER_MAIL) TYPE SO_OBJ_DES
*" TABLES
*" LIST_FAX_MAIL_NUMBER STRUCTURE SOLI
*" EXCEPTIONS
*" ERR_NO_ABAP_SPOOLJOB
DATA: vg_achou(1) TYPE n.
Fist part: Verify if the spool really exists
vg_achou = 1.
DO 60 TIMES.
SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
IF sy-subrc IS INITIAL.
CLEAR vg_achou.
EXIT.
ELSE.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDDO.
IF vg_achou = 1.
RAISE err_no_abap_spooljob. "doesn't exist
ENDIF.
client = tsp01-rqclient.
name = tsp01-rqo1name.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = client
name = name
part = 1
IMPORTING
type = type
objtype = objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4
OTHERS = 5.
IF objtype(3) = 'OTF'.
desired_type = otf.
ELSE.
desired_type = ali.
ENDIF.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = src_spoolid
desired_type = desired_type
IMPORTING
real_type = real_type
TABLES
buffer = l_objcont
EXCEPTIONS
no_such_job = 14
type_no_match = 94
job_contains_no_data = 54
no_permission = 21
can_not_access = 21
read_error = 54.
IF sy-subrc EQ 0.
attach_type = real_type.
ENDIF.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
owner = sy-uname
region = ou_fol
IMPORTING
folder_id = l_folder_id
EXCEPTIONS
OTHERS = 5.
fill out informations about the header of the email
CLEAR: g_document.
g_document-foltp = l_folder_id-foltp.
g_document-folyr = l_folder_id-folyr.
g_document-folno = l_folder_id-folno.
g_document-objtp = c_objtp.
g_document-objdes = header_mail.
g_document-file_ext = c_file_ext.
g_header_data-objdes = header_mail.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'SAVE'
office_user = sy-uname
IMPORTING
authority = g_authority
TABLES
attachments = lt_attachments
CHANGING
document = g_document
header_data = g_header_data
EXCEPTIONS
OTHERS = 1.
folder_id-objtp = l_folder_id-foltp.
folder_id-objyr = l_folder_id-folyr.
folder_id-objno = l_folder_id-folno.
object_id-objtp = c_objtp.
object_id-objyr = g_document-objyr.
object_id-objno = g_document-objno.
link_folder_id-objtp = l_folder_id-foltp.
link_folder_id-objyr = l_folder_id-folyr.
link_folder_id-objno = l_folder_id-folno.
REFRESH lt_rec_tab.
LOOP AT LIST_FAX_MAIL_NUMBER.
lt_rec_tab-recextnam = LIST_FAX_MAIL_NUMBER-LINE.
lt_rec_tab-recesc = 'U'.
lt_rec_tab-sndart = 'INT'.
lt_rec_tab-sndpri = 1.
APPEND lt_rec_tab.
ENDLOOP.
lt_files-file = c_file.
APPEND lt_files.
hd_dat-objdes = header_mail.
CALL FUNCTION 'SO_ATTACHMENT_INSERT'
EXPORTING
object_id = object_id
attach_type = attach_type
object_hd_change = hd_dat
owner = sy-uname
TABLES
objcont = l_objcont
objhead = l_objhead
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
object_type_not_exist = 17
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
x_error = 1000.
IF sy-subrc > 0.
ENDIF.
send email from SAPOFFICE
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
folder_id = folder_id
object_id = object_id
outbox_flag = outbox_flag
link_folder_id = link_folder_id
owner = sy-uname
TABLES
receivers = lt_rec_tab
note_text = lt_note_text
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
component_not_available = 1
folder_no_authorization = 5
folder_not_exist = 6
forwarder_not_exist = 8
object_no_authorization = 13
object_not_exist = 14
object_not_sent = 15
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
too_much_receivers = 73
user_not_exist = 35.
ENDFUNCTION.
Regards,
Sree -
Hi friends,
I have an internal table with the following fields:
salesordernumber itemnumber etcetc
I want the output as below:
salesordernumber itemnumber1
itemnumber2
(if the salesordernumber has multiple items, the itemnumber2 should come exactly below itemnumber1)
or just
salesordernumber itemnumber (and go for the next sales order if it has single item)
Please suggest a code.
Thanks.Hi Nuren,
Please check this piece of code.
TYPES : BEGIN OF ty_itab,
f1,
f2(10),
END OF ty_itab.
DATA : itab TYPE TABLE OF ty_itab WITH HEADER LINE.
itab-f1 = 'A'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'A'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'B'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'B'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'C'.
itab-f2 = 'GANGA'.
APPEND itab.
LOOP AT itab.
AT NEW f1.
WRITE: /5 itab-f1, 10 itab-f2.
ENDAT.
WRITE: /10 itab-f2.
ENDLOOP.
Output will be :
A *************
GANGA
GANGA
B *************
GANGA
GANGA
C *************
GANGA
Hope this what u require. If found helpful, please do reward. -
Download Internal Table in CSV format it gets downloaded in single column
Hi All
I am converting Internal Table in CSV format using the FM CONVERT TO CSV FORMAT and then downloading data using GUI_DOWNLOAD FM.
I have given separator as ','.
However when I download the data the file is opened in Excel and first 2 to 3 column are merged in to single column and there was separator shown ';'.
How to overcome this problem.
AmolhI..,
Check this code..
<b>
It first downloads the data in internal table to a CSV format file..
and then uploads the same data into another internal table and prints it..</b>
analyze this and use accordingly..
tables:
spfli.
field-symbols : <fs>, <fs1>.
data:
w_line(1000),
w_field(20) type c,
wa_spfli type spfli.
data:
begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
countryto type spfli-countryto,
fltime type spfli-fltime,
end of fs_spfli.
data :
t_file like standard table
of w_line
initial size 0.
data:
t_spfli like
standard table
of fs_spfli
initial size 0.
data:
t_spfli_up like
standard table
of fs_spfli
initial size 0.
select carrid
connid
countryfr
countryto
fltime
into corresponding fields of table t_spfli
from spfli.
loop at t_spfli into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
w_field = <fs>.
condense w_field no-gaps.
if sy-index eq 1.
w_line = w_field.
else.
concatenate w_line ',' w_field into w_line.
endif.
enddo.
append w_line to t_file.
endloop.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'D:\file.txt'
filetype = 'ASC'
APPEND = ' '
write_field_separator = ' '
header = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = t_FILE
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear t_FILE.
call function 'GUI_UPLOAD'
exporting
filename = 'D:\file.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = t_FILE
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear fs_spfli.
*constants :
*C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
loop at t_file into w_line.
do.
if w_line eq space.
exit.
endif.
split w_line at ',' into w_field w_line.
condense w_field no-gaps.
assign component sy-index of structure fs_spfli to <fs>.
<fs> = w_field.
enddo.
append fs_spfli to t_spfli_up.
endloop.
loop at t_spfli_up into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
write <fs>.
enddo.
skip.
endloop.
reward if it helps u..
sai ramesh -
Query statement for internal table
is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx
Hi Daphne,
You use SELECT statement to read data from database table but not from Internal table.
For reading data from Internal table, you have to use READ statement.
Syntax:
READ TABLE itab { table_key
| free_key
| index } result.
Effect of using read statement:
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
Reward if usefull
thanks
swaroop -
Download into CSV format from internal table
Hi,
I would like to download my internal table records in CSV format without any manual formating.
It is easy to concatenate internal table fields into a string with ',' seperator. But I would like to do in a better way that this becasue of more number of fields in my internal table.
Could you someone help me in this, I have searched in this form for help I found few function modules which did not help me.
SAP_CONVERT_TO_CSV_FORMAT / LIST_DOWNLOAD .
Prabhu Rajesh.Sravan,
type-pools: truxs.
DATA : BEGIN OF itab OCCURS 0,
name1(10),
name2(10),
END OF itab.
DATA : itab1 TYPE truxs_t_text_data.
DO 10 TIMES.
itab-name1 = 'Prabhu'.
itab-name2 = 'Rajesh'.
APPEND itab.
CLEAR : itab.
ENDDO.
LOOP AT itab.
WRITE:/ itab-name1, itab-name2.
ENDLOOP.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ';'
I_LINE_HEADER =
i_filename =
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Maybe you are looking for
-
Create SOAPMessage object from existing XML file
Say I have already had a SOAP Message in a .xml file format. How can I create a SOAPMessage object in my program by loading the .xml file directly into it as opposed to using those getEnvelope(), getSOAPPart(). to build it piecemeal?
-
Update Results not Displayed in Oracle Text search with Transactional Index
Hi, I am working on a solution utilising Oracle Text to give me a probable list of matching records. The problem I have the table I am searching on is prepopulated with seed data and the application we are building is assigning a record and updating
-
I've got Windows XP and Photoshop Elements 4.0. 20,100 photos taking 10.3 MB of data. Backed up on external hard drive using Sybase software. This backs up the Windows files containing the pictures. It doesn't back up the Adobe catalog construct.
-
PSE9 opens randomly Camera raw 5.6 and 6.4.1
Hi! My problem is, that PSE9 opens my raw photos seemingly in random wirh either Camera Raw 5.6 or 6.4.1. I don´t know why. I have updated to Camera Raw 6.4.1 for many monts ago, and this old 5.6 version pops up now and then. My Camera is Canon 7D an
-
Error: Dynamic Link not available
Hi all, When loading a music file into CS6 I get an error message "Could not complete your request because DynamicLink is not avaliable" Can you help me I have just load this program and want to do some video work? Ange