Urgent...simple internal table problem
Hi gurus
i am filling a internal table like this
loop at i_0001 into s_0001.
clear out_final.
out_final-pernr = s_0001-pernr.
out_final-parea = s_0001-parea.
loop at i_0021 into s_0021 where pernr = s_0001-pernr and subty ne '7'.
perform rec1.
endloop.
loop at i_0106 into s_0106 where pernr = s_0001-pernr and subty ne '7'.
perform rec2.
append out_final to i_final.
clear out_final.
endloop.
and my performs are
FORM rec1.
read table i_0021 into s_0021 with key pernr = s_0001-pernr.
out_final-fname = s_0021-fname.
out_final-lname = s_0021-lname.
out_final-bdate = s_0021-bdate.
ENDFORM. " rec1
FORM rec2.
read table i_0106 into s_0106 with key pernr = s_0001-pernr.
out_final-ssn = s_0106-ssn.
out_final-add1 = s_0106-add1.
out_final-add2 = s_0106-add2.
out_final-city = s_0106-city.
out_final-state = s_0106-state.
out_final-country = s_0106-country.
out_final-zip = s_0106-zip.
out_final-hphone = s_0106-hphone.
ENDFORM. " rec2
all my declerations and syntax are correct
now i have 2 simple things to ask
1. when i write data i get duplicate records ....is my loop , clear and append are in right place
2. i wan to delimit this data for a condition where bdate is greater than 18. bdate is of type p0021-fgbdt which i have to format using some FM....how do i do that where do i have to add code for that.
thanks in advance
plz help
regards
Hi,
Check the below code.
loop at i_0001 into s_0001.
clear out_final.
out_final-pernr = s_0001-pernr.
out_final-parea = s_0001-parea.
<b>*****loop at i_0021 into s_0021 where pernr = s_0001-pernr and subty ne '7'.</b>
perform rec1.
<b>***endloop.
****loop at i_0106 into s_0106 where pernr = s_0001-pernr and subty ne '7'.</b>perform rec2.
<b>if not out_final is initial.</b>
append out_final to i_final.
<b>endif.</b>
clear out_final.
endloop.
and my performs are
FORM rec1.
read table i_0021 into s_0021 with key pernr = s_0001-pernr
<b>subty ne '7'.</b>
<b>if sy-subrc = 0.</b>
out_final-fname = s_0021-fname.
out_final-lname = s_0021-lname.
out_final-bdate = s_0021-bdate.
<b>endif.</b>
ENDFORM. " rec1
FORM rec2.
read table i_0106 into s_0106 with key pernr = s_0001-pernr
<b>subty ne '7'.</b>
<b>if sy-subrc = 0.</b>
out_final-ssn = s_0106-ssn.
out_final-add1 = s_0106-add1.
out_final-add2 = s_0106-add2.
out_final-city = s_0106-city.
out_final-state = s_0106-state.
out_final-country = s_0106-country.
out_final-zip = s_0106-zip.
out_final-hphone = s_0106-hphone.
<b>endif.</b>
ENDFORM. " rec2
<b></b><b></b>
Hope this will solve ur duplication problem
Similar Messages
-
Bdc upload file data into internal table problem with gui_upload fm
Hello experts,
my coding is like this ..
data : begin of itab occurs 0 .
field1 like mara-matnr,
field2......
etc,
end of itab.
data: file1 type string.
parameter :file like rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
mask = space
field_name = 'FILE'
CHANGING
file_name = file.
START-OF-SELECTION.
FILE1 = FILE . "HERE I AM PASSING INTO STRING
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = FILE1
FILETYPE = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab. " here the data is not populating from the file , it is giving the error like speified table not found.
HERE i am getting the message like "specified table name not recgonised" . the data is not populating into the itab from the file.
file structure is same as the internal table.
I stored the file as .txt( ie in notepad).
my file is like this..
10000 200 323 sunndarrr.......
i had a problem with this bdc , i am getting like "specified table name not recgonised" in the fm gui_upload while debugging.
when i am using the ws_upload it is working fine.
please guide me where i have done the mistake.
thank you so much for all the replies.Hi,
Have a look on the following code.
TABLES: kna1.
DATA: BEGIN OF itab1 OCCURS 0,
str(255),
END OF itab1.
DATA: itab2 TYPE kna1 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'D:\ABAP EVE\ffile1.txt'
filetype = 'ASC'
TABLES
data_tab = itab1
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
OTHERS = 11.
IF sy-subrc <> 0.
WRITE:/ 'sorry'.
ELSE.
LOOP AT itab1.
SPLIT itab1-str AT ',' INTO itab2-kunnr itab2-name1.
APPEND itab2.
ENDLOOP.
IF sy-subrc = 0.
LOOP AT itab2.
WRITE:/ itab2-kunnr,itab2-name1.
INSERT INTO kna1 VALUES itab2.
ENDLOOP.
IF sy-subrc = 0.
WRITE:/ 'inserted'.
ELSE.
WRITE:/ 'not inserted'.
ENDIF.
ELSE.
WRITE:/ 'fail'.
ENDIF.
ENDIF.
Flat file:
10001,Sadney
10003,Yogesh
20005,Madan
1.U need to define internal table with one field of max size
2.upload the flat file data into that internal table
3.split that internal table data into another internal table(having fields)
<REMOVED BY MODERATOR>
thanks,
Chandu
Edited by: Alvaro Tejada Galindo on Apr 30, 2008 12:17 PM -
Dynamic internal table problem in FM - HR_INFOTYPE_OPERATIONS
Dear All,
I have a problem when I use a Dynamic internal table in FM - HR_INFOTYPE_OPERTATION..
Please suggest me on the way to overcome this problem..
We wanted to have a dynamic Program for Info type operations which can be used for any info types as we are changing only BEGDA and the related actions
So in my program I have the parameters to accept
P_BEGDA - 01.10.2007
P_INFTY - P0008
P_ACTIO - COPY
I am able to create a dynamic table based on the parameters P_INFTY and able to read it also using the FM - HR_READ_INFOTYPE
BUT when I pass the dynamic internal table to a FM - HR_INFOTYPE_OPERTATION I am getting a DUMP
The DUMP is at the below statement from FM - HR_INFOTYPE_OPERTATION
ASSIGN record TO <record> CASTING TYPE (tabname). "XDP UniCode
It gives the below possiblities
"ASSIGN_BASE_TOO_SHORT" C
"SAPLHRMM" or "LHRMMU03"
"HR_INFOTYPE_OPERATION"
But If I use the below internal table
Data : g_t_0008 like P0008 occurs 0 with header line.
And If I use the internal table g_t_0008 instead of dynamic tables then it works. So I strongly feel it's due to not having a header in the dynamic table below see below the sample code on how I am generating a dynamic internal table
field-symbols: <dyn_table> type standard table.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
to get the srurcute
perform get_structure using l_f_table.
perform create_dynamic_itab .
assign dy_table->* to <dyn_table>.
perform get_data tables <dyn_table01>
using pernr-pernr p_infty.
below are the forms routine .
form get_structure using p_table.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
clear : ifc[], dy_table.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
endform.
*& Form get_data
form get_data tables p_table
using p_pernr
p_infty.
clear : p_table, p_table[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
PERNR = P_PERNR
INFTY = p_infty
BEGDA = p_datum
ENDDA = p_datum
TABLES
INFTY_TAB = p_table
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2.
CHECK SY-SUBRC EQ 0.
IF lines( p_table ) GT 0.
*write :/'Record exist' , 'IT', p_infty.
clear p_table.
PERFORM hr_operation tables p_table
using g_t_t588d-actio g_t_t588d-INFTY
g_t_t588d-SUBTY.
else.
PERFORM append_status using g_t_itab-pernr p_infty ' '
'Error' 'No records'.
ENDIF.
endform. " get_data
form hr_operation tables p_table
using p_actio P_INFTY P_SUBTY.
data: l_f_return LIKE bapireturn1.
ASSIGN COMPONENT 'BEGDA' OF STRUCTURE p_table TO <l_field>.
<l_field> = p_begda.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = P_infty
number = G_T_ITAB-PERNR
subtype = P_subty
validityend = g_f_endda
validitybegin = P_datum
record = P_TABLE
operation = p_actio
IMPORTING
return = l_f_return.
IF sy-subrc NE 0.
ENDIF.
ENDFORM.try
using field symbol for a wrk area instead of Field symbol for a table
loop your inernal table (again a field symbol) assigning to <fs_wrkarea>
in loop call HR_INFO.._OP..
reward if helpful -
Smartform loop into internal table problem
hello experts,
i am doing an example given in **************** regarding smartforms. I am getting problem which doing the smartforms . please help me.
http://****************/Tutorials/Smartforms/SFMain.htm
in that i am doing the program
Working with loop.
I have done exactly as the screen shots in the program.
Now in the main window i created a loop.
in that loop i am not getting the option internal table.
But it is showing as operand . It is in the data tab of the loop.
I searched the all the tabs in the loop but did not find the option internal table.
so then i ticked the operand and i did as speified in the screen shots.
it_tab into fs_tab
Then i created a text and then placed &fs_tab-vbeln& etc.
then i executed the smartform now in the output i am not getting the sales order number , item etc.
The output is showing like
&fs_tab-vbeln& &fs_tab-posnr& etc.
please guide me how to get the internal table option in the loop. And also tell me how to rectify this problemthanks for all the replies.
I will give all at the time of closing my thread.
Hi Sravanthi -> in loop node i am not getting the internal table insted of that i am getting operand in the data tab.
This is my main problem.I dont why operand is comming there.
my version is 4.7e
Hi Karthik and swati -> i simply hard coded the statements in the text as shown in the example.
Now i will try with the add field.
But please tell me why i am not getting internal table option in loop. -
Hi Friends,
I am not an expert in ABAP, but I seem to have a weird problem with the following piece of code. When I uncomment the write statement in the first loop code and execute, it actually displays values for
itab_zsel-zdate1, itab_zsel-ztime1, itab_zsel-zhr, itab_zsel-zvar_log.
But
when I have the code exactly as shown below, it displays just the itab_zsel-zdate1, itab_zsel-ztime1 and not itab_zsel-zvar_log
Can you tell me wht is wrong with this code?
itab_log and itab_sel are internal tables
loop at itab_log.
loop at itab_zsel where zdate1 = itab_log-zbatchdate and zhr = itab_log-zhrmin.
itab_zsel-zvar_log = itab_log-zlogid.
modify table itab_zsel.
*write:/ itab_zsel-zdate1, itab_zsel-ztime1, itab_zsel-zhr, itab_zsel-zvar_log.
endloop.
endloop.
loop at itab_zsel.
write:/ itab_zsel-zdate1, itab_zsel-ztime1, itab_zsel-zvar_log.
endloop.
Thank youHi Deepthi,
I did not understand what you are trying to do,
but try this and see if it helps
loop at itab_log.
clear lw_tabix.
lw_tabix =sy-tabix.
read table itab_zsel with key zdate1 = itab_log-zbatchdate zhr = itab_log-zhrmin.
if sy-subrc = 0.
itab_zsel-zvar_log = itab_log-zlogid.
modify itab_zsel index lw_tabix.
*write:/ itab_zsel-zdate1, itab_zsel-ztime1, itab_zsel-zhr, itab_zsel-zvar_log.
endif.
endloop.
loop at itab_zsel.
write:/ itab_zsel-zdate1, itab_zsel-ztime1, itab_zsel-zvar_log.
endloop.
Regards,
Ravi -
Dynamic ALV Internal table Problem
Hi all,I have successfully built an IT using method 'create_dynamic_table'.But my problems are :
1)When Iam trying to select the data with multiple tables then it is short dumping.
2)I tried to oselect the data using one table,after selecting the data if I use FM REUSE_ALV_Grid_Display then it is showing short dump with error 'type conflict when calling FM'.
I never used field symbols before.PLZ complete my program or give me suffecient feedback.Here is my program :
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data.
DATA : dats LIKE vbbe-mbdat,
t_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>,
<dyn_field>.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR dats.
SELECTION-SCREEN END OF BLOCK blk1.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-seltext = 'Material Number'.
wa_fieldcat-intlen = '18'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MAKT'.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'MBDAT'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'OMENG'.
wa_fieldcat-datatype = 'QUAN'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
DATA : d TYPE i,
v(02) TYPE n VALUE '0',
day(8) TYPE c.
d = s_mbdat-high - s_mbdat-low + 1.
DO d TIMES.
v = v + 1.
CONCATENATE 'Day' v INTO day.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = day.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-seltext = day.
wa_fieldcat-intlen = '8'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
ENDDO.
*-----Building Dynamic internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
SELECT m~werks m~matnr v~omeng v~mbdat INTO CORRESPONDING FIELDS
OF TABLE <it_dyn> FROM mska AS m INNER JOIN vbbe AS v
ON m~posnr = v~posnr WHERE v~mbdat IN s_mbdat.*DATA : d TYPE i,
v(02) TYPE n VALUE '0',
day(8) TYPE c.
*d = s_mbdat-high - s_mbdat-low + 1.
*DO d TIMES.
v = v + 1.
CONCATENATE 'Day' v INTO day.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = day.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-seltext = day.
wa_fieldcat-intlen = '8'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
*ENDDO.
*-----Building Dynamic internal table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
SELECT OMENG FROM VBBE INTO CORRESPONDING FIELDS OF TABLE <IT_DYN> WHERE MBDAT IN S_MBDAT.
BREAK-POINT.
YOU WILL GET VALUES IN INTERNAL TABLE.
TO SOLVE YOUR ISSUE YOU SHOULD USE NUM INSTEAD OF DATS. -
Hi..
I have 2 programs with me.
In the first program my code is like this
REPORT Y_TEST1.
DATA:
BEGIN OF FS_DATA,
NUMBER TYPE I,
NAME(30) TYPE C,
END OF FS_DATA.
DATA:
T_DATA LIKE STANDARD TABLE OF FS_DATA.
DEFINE APPEND_TABLE.
FS_DATA-NUMBER = &1.
FS_DATA-NAME = &2.
APPEND FS_DATA TO T_DATA.
CLEAR FS_DATA.
END-OF-DEFINITION.
APPEND_TABLE 1 'HARISH'.
APPEND_TABLE 2 'MAHESH'.
APPEND_TABLE 3 'SURESH'.
APPEND_TABLE 4 'WAJID'.
APPEND_TABLE 5 'SANKAR'.
APPEND_TABLE 6 'SATISH'.
APPEND_TABLE 7 'CHANDU'.
APPEND_TABLE 8 'VEERESH'.
EXPORT T_DATA TO MEMORY ID 'NAM'.
SUBMIT Y_TEST1_CALLED.
And my Second Program code is ..
REPORT Y_TEST1_CALLED.
DATA:
FS_DATA(30).
DATA:
T_DATA LIKE STANDARD TABLE OF FS_DATA.
IMPORT T_DATA FROM MEMORY ID 'NAM' . ******ERROR
LOOP AT T_DATA INTO FS_DATA.
WRITE: / FS_DATA.
ENDLOOP.
These are the programs that i have here in
second Prog i am getting Shortdump as Types mis match ..
but according to my requirement i need to get the data into itab t_data without changing structure of the internal tables ,
here I need to use any of options in IMPORT
{ { { {[ACCEPTING PADDING] [ACCEPTING TRUNCATION]}
| [IGNORING STRUCTURE BOUNDARIES] }
[IGNORING CONVERSION ERRORS [REPLACEMENT CHARACTER rc]] }
| [IN CHAR-TO-HEX MODE] }
[CODEPAGE INTO cp]
[ENDIAN INTO endian].
what i need to use and how ......
i think correct option is IGNORING CONVERSION ERRORS but it is giving syntax error ..can any one send me the proper code and my system is ECC 5.Hi Pasupulati,
Please try it in this way. I have already done it in my one requirement.
Hi,
Please use it in this way,
*& First Prog----
data: char4(4) type c.
EXPORT char4 TO MEMORY ID 'ZOT'.
*& Other Prog---
Data: char4(4) type c.
IMPORT char4 FROM MEMORY ID 'ZOT'.
Once you get the output.
Then Free the Memory
syntax is:
Free memory id 'ZOT'. -
Internal table problem for BDC
Hai i am having flatfile like this format
H text1 1000 plant_name 10 short_text X X
20 short_text X X
30 short_text X X
H text1 1000 plant_name 10 short_text X X
20 short_text X X
30 short_text X X
now this H indicates new record. In each new record number of line items are there.
How to proceed using internal tables. please help me.hi,
arrange your flat file like this...
H text1 1000 plant_name 10 short_text X X
H text1 1000 plant_name 20 short_text X X
H text1 1000 plant_name 30 short_text X X
H1 text1 1000 plant_name 10 short_text X X
H1 text1 1000 plant_name 20 short_text X X
H1 text1 1000 plant_name 30 short_text X X
now make an internal table having all the fields present in your flat file
and loop at that internal table and on change of field H call your function module and pass the value for record H......
similarly it will work for H1.....H2.....
for eg...
LOOP AT "Your internal table" INTO "Work area of your internal table".
AT END OF "field name for H".
CALL FUNCTION ''Your function module" -
Dynamic Internal Table problem
Hello all,
I have created a Dynamic ALV using RTTS classes like cl_abap_structdescr,cl_abap_tabledescr and cl_abap_datadescr.
The number of columns to be displayed is dynamic and i am able to display the same.
Now i need to perform SUBTOTAL on few of the columns.
In dynamic table how do i assign those columns as Type 'I' so that i can perform DO_SUM.
I used the method GET_I of class cl_abap_elemdescr but unable to achive the same.
Kindly suggest.
Regards,
ArunI know when I need to create a dynamic alv I use the following (plumbing code removed).
DATA: it_field_catalog TYPE lvc_t_fcat.
DATA: dyn_table TYPE REF TO data.
FIELD-SYMBOLS: <dyn_table> TYPE table.
create your alv as normal. Or auto create the entries based on the tables, whatever conditions you use to determine the structure of the table at run time.
ls_fcat-fieldname = '???'.
ls_fcat-inttype = '?' .
ls_fcat-outputlen = '?' .
ls_fcat-coltext = '?' .
ls_fcat-seltext = '?' .
ls_fcat-f4availabl = '?'.
ls_fcat-edit = '?'.
ls_fcat-key = '?'.
APPEND ls_fcat TO it_field_catalog .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = it_field_catalog
IMPORTING ep_table = dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1.
ASSIGN dyn_table->* TO <dyn_table>.
This field symbol to the table can then be passed in place of the table when calling your alv and performing operations on it. -
Export Internal Table To E-Mail via attachted html or PDF file
i have an ALV display report for which the data is in the internal table.
Can anybody tell me how can i attach the simple internal table as an attachment to the mail ...
give me example code if possible
Maximum points will be given
thanks in advance.here is the sample code but this code gives you two attachemetns as .xls files you try analyse and try it for PDF
you have to change in the packed_list parameter that is passed to the FM.
REPORT ZDOC_AS_EMAIL_3.
*& Report ZEMAIL_ATTACH *
*& Example of sending external email via SAPCONNECT *
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: l_t_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
*Retrieve sample data from table ekpo
PERFORM data_retrieval.
*Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
*Populate message body text
perform populate_email_message_body.
*Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example . xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
*Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
*Build data table for .xls document
FORM build_xls_data_table.
*CONSTANTS: con_cret(2) TYPE c VALUE '0D', "OK for non Unicode
*con_tab(2) TYPE c VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
*Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
*Fill the document data.
w_doc_data-doc_size = 1.
*Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'REPORT'.
w_doc_data-obj_descr = ld_mtitle . "mail description
w_doc_data-sensitivty = 'F'.
*Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
*Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
*Create 1st attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 0.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
**Create 1st attachment notification
*t_packing_list-transf_bin = 'X'.
*t_packing_list-head_start = 0.
*t_packing_list-head_num = 1.
*t_packing_list-body_start = 1.
*DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
*t_packing_list-doc_type = ld_format.
*t_packing_list-obj_descr = ld_attdescription.
*t_packing_list-obj_name = ld_attfilename.
*t_packing_list-doc_size = t_packing_list-body_num * 255.
*APPEND t_packing_list.
**Create 2nd attachment notification
data: x type i.
DESCRIBE TABLE t_attachment LINES X.
append lines of it_attach to t_attachment.
data: start type i,
end type i,
cal type i.
start = X + 1.
describe table t_attachment lines end.
cal = end - start.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 0.
t_packing_list-head_num = 1.
t_packing_list-body_start = start.
t_packing_list-body_num = end.
*DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-obj_descr = 'Eng Change'. "ld_attdescription.
t_packing_list-doc_type = ld_format.
*t_packing_list-obj_name = 'Eng' .
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
*Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
object_header = l_t_objhead
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
*Populate zerror return code
ld_error = sy-subrc.
*Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 " WITH mode = 'INT'
"WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
*Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
Edited by: S@N on Jun 13, 2008 2:06 PM -
Upload data into internal table
Hi All,
could you help me on this plaese,
i want to convert the text data into the internal table.
problem is in my notepad i having the field names and values
i want to upload that total data into my internal table.
i.e in notepad having like this
NAME NUMBER }------ field names
NARESH 222 }------ values
KUMAR 333
REDDY 444
this is tha data, now i want to upload field name s as well as values.
thanks,
nareshHi ,
call following function module
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'PC_FILE' <----
File name
FILETYPE = u2018ASCu2019
HAS_FIELD_SEPARATOR = 'X'
DAT_MODE = 'X'
TABLES
DATA_TAB = 'Your internal Table' <-------Internal table name
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. -
Urgent problem: grouping by fields of internal table
Hi friend,
i have a urgent problem and i hope that you can help me out:
i have an internal table containing data, and i sorted it by 3 fields.
now what i want to do is kind of grouping that means that all the lines that are the same should be written into another internal table like this:
A
A
B
B
B
C
D
would give me:
A 1
A 1
B 2
B 2
B 2
C 3
D 4
How could i do this ( especially avoiding nested loops ? ) Is there a handy trick to do this efficiently ?
thank you, i will give points immediately,
ClemensHello,
The field position is important for the fields that are using in the control break statements..Also SORT internal table is required.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
VALUE TYPE NETPR,
END OF ITAB.
ITAB-MATNR = 'ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
ITAB-MATNR = '1ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
SORT ITAB BY MATNR WERKS.
LOOP AT ITAB.
AT FIRST.
WRITE : 'AT FIRST'.
ENDAT.
AT NEW MATNR.
WRITE : 'AT NEW MATERIAL NUMBER'.
ENDAT.
AT END OF MATNR.
SUM.
WRITE: / ITAB-MATNR, 'MATERIAL TOTAL - ', ITAB-VALUE.
ENDAT.
AT END OF WERKS.
SUM.
WRITE: / ITAB-WERKS, 'PLANT TOTAL - ', ITAB-VALUE.
ENDAT.
AT LAST.
WRITE : 'AT LAST'.
ENDAT.
ENDLOOP.
Regards,
Deepu.K -
Problem in Summing the value in one internal table. Its very urgent.
Hi Experts,
I have 10 fields in one internal table and based on the 8th field changing, I have to sum the 3rd field.
I am unable to use AT END OF <FIELD8>, because any of the fields from 1 to 7 are changing, then this control break statement triggering.
Could any body tell me, how I have to do this.
Thanks,
bsv.Hi,
I think it could be as simple as below.
DATA: l_field8 TYPE bla bla.
READ TABLE itab
INTO wa_itab
INDEX 1.
l_field8 = wa_itab-field8.
LOOP AT itab INTO wa_itab.
IF l_field8 NE wa_itab-field8.
"Do the sum here
ENDIF.
ENDLOOP.
Regards,
Teddy
Edited by: Teddy Kurniawan on Jan 25, 2008 8:38 AM -
Simple Transformation - XML to Internal Table Error
I have a webservice call that returns XML. I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing. I have read through most posts regarding the topic but they're either too old or related to serialization. There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root). Below are some code snippets. Any ideas on the problem with the XSLT template? Thanks.
Sample XML:
<?xml version="1.0" encoding="utf-8" ?>
<PrintVersionDataSet>
<Result>
<ReturnCode>W</ReturnCode>
<ReturnMessage>There are reports with later version(s)</ReturnMessage>
</Result>
<Paperwork>
<ReportCode>CVR</ReportCode>
<ReportName>Cover Sheet</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime>
</Paperwork>
<Paperwork>
<ReportCode>SPS</ReportCode>
<ReportName>Sponsor Summary</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime>
</Paperwork>
</PrintVersionDataSet>
XSLT Code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="RESULT"/>
<tt:root name="PAPERWORK"/>
<tt:template>
<PrintVersionDataSet>
<Result tt:ref="RESULT">
<ReturnCode>
<tt:value ref="RETURNCODE"/>
</ReturnCode>
<ReturnMessage>
<tt:value ref="RETURNMESSAGE"/>
</ReturnMessage>
</Result>
<tt:deserialize>
<tt:loop ref=".PAPERWORK">
<Paperwork>
<ReportCode>
<tt:value ref="REPORTCODE"/>
</ReportCode>
<ReportName>
<tt:value ref="REPORTNAME"/>
</ReportName>
<Version>
<tt:value ref="VERSION"/>
</Version>
<PrintedDateTime>
<tt:value ref="PRINTEDDATETIME"/>
</PrintedDateTime>
</Paperwork>
</tt:loop>
</tt:deserialize>
</PrintVersionDataSet>
</tt:template>
</tt:transform>
ABAP Call to Transform Data:
TRY.
CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC
SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT
RESULT RESULT = LS_RESULT
PAPERWORK = LT_PAPERWORK.
CATCH CX_ROOT INTO ROOT_EXCEPTION.
CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT
RECEIVING
RESULT = LV_MESSAGE.
ENDTRY.Upon further inspection and testing with a simple file and program, I can see that the XML structure isn't quite correct for the loop process. There needs to be a single <PAPERWORK> node, instead of one for each table line in the file. This should allow the loop to execute properly after a slight adjustment to the XSLT template.
-
Problem with downloading the internal table onto the presentation server.
Hey folks,
I have a problem where in i am downloading one year of sales done by the company. I wrote a program to download the file onto the presentation server . The error occurs in the FM GUI_DOWNLOAD where if the file exceeds 105843504 bytes its giving me a dump saying that
When the program was running , it was established that more memory was needed than the operating system is able to safely to provide.
The current program has to be terminted because of the program already requested 105843504 bytes from the operating system with malloc when the operating system reported after further memory request that there was no more memory space available.
Could somebody provide an alternative soltuion for this.
Its really urgent as i can download the file with 70,000,000 bytes
Regards
RockHi Rock,
Please download the files on to Application Server, else as suggested by Ashish download into 2 or 3 files and merge them manually.
Declare same internal tables may be 5 times.
When you fill the internal table check for a counter and when you hit a certain number stop appending to it and start appending to the next.
After you are done so download all the internal tables.
I guess this would be a good way. I am not sure if there are any ther alternative good methods.
Hope this helps.
Shreekant
Maybe you are looking for
-
Spry Accordion Widget Behavior
I am using Dreamweaver CS3 and several Spry components. I am new to using Spry, but like how easy it is to impliment. One of the components I am trying to use is the Accordion Widget. The widget appears to function well (I am using variable panel hei
-
I want to keep one item in my shot in color and the rest of the clip in black and white. I know this is possible, but I don't know what tools or filters to use for it. *Any help would be awesome.*
-
External mic not detected? (R705)
Hi all, I recently got an R705 but am having an issue with the mics. Somehow the computer can't detect any external mics that I have plugged in too the mic jack, and in turn doesn't disable the internal one. Whatever I try to record just gets picked
-
please help
-
Cross Dissolves: quick way to add just ONE!?
So i've updated to the newest update of final cut x, but i'm still hung up on adding cross dissolves i have two clips on my timeline, i want to add a cross dissolve between the two cuts. so i right click between the two and choose 'add cross dissolve