How to check internal table sorted or not
Hi all
I need to check internal table sorted or not which is without header line and having only one field and six values. please let me know how to check it is sorted or not because i need to display message if it is not sorted.
thanks,
Minal
Hi Minal,
Go through this info.
Sorted tables
This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
Stable sort
The option
SORT <itab> ... STABLE.
allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
Examples
DATA: BEGIN OF LINE,
LAND(3) TYPE C,
NAME(10) TYPE C,
AGE TYPE I,
WEIGHT TYPE P DECIMALS 2,
END OF LINE.
DATA ITAB LIKE STANDARD TABLE OF LINE WITH NON-UNIQUE KEY LAND.
LINE-LAND = 'G'. LINE-NAME = 'Hans'.
LINE-AGE = 20. LINE-WEIGHT = '80.00'.
APPEND LINE TO ITAB.
LINE-LAND = 'USA'. LINE-NAME = 'Nancy'.
LINE-AGE = 35. LINE-WEIGHT = '45.00'.
APPEND LINE TO ITAB.
LINE-LAND = 'USA'. LINE-NAME = 'Howard'.
LINE-AGE = 40. LINE-WEIGHT = '95.00'.
APPEND LINE TO ITAB.
LINE-LAND = 'GB'. LINE-NAME = 'Jenny'.
LINE-AGE = 18. LINE-WEIGHT = '50.00'.
APPEND LINE TO ITAB.
LINE-LAND = 'F'. LINE-NAME = 'Michele'.
LINE-AGE = 30. LINE-WEIGHT = '60.00'.
APPEND LINE TO ITAB.
LINE-LAND = 'G'. LINE-NAME = 'Karl'.
LINE-AGE = 60. LINE-WEIGHT = '75.00'.
APPEND LINE TO ITAB.
PERFORM LOOP_AT_ITAB.
SORT ITAB.
PERFORM LOOP_AT_ITAB.
SORT ITAB.
PERFORM LOOP_AT_ITAB.
SORT ITAB STABLE.
PERFORM LOOP_AT_ITAB.
SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
PERFORM LOOP_AT_ITAB.
FORM LOOP_AT_ITAB.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-LAND, LINE-NAME, LINE-AGE, LINE-WEIGHT.
ENDLOOP.
SKIP.
ENDFORM.
************rewords some points if it is helpful.
Rgds,
P.Naganjana Reddy
Similar Messages
-
How to check one table exist or not in SAP
Hi, Gurus:
How to check one table exist or not in the SAP.
Thanks,Hi,
Query the table DD02L..
Select single * from DD02L where tabname = 'Your table name'
AND TABCLASS = 'TRANSP'. " For transparent tables.
Thanks
Naren -
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf INTO gd_buffer.
* ENDLOOP.
* TRANSLATE gd_buffer USING '~ '.
* DO.
* it_mess_att = gd_buffer.
* APPEND it_mess_att.
* SHIFT gd_buffer LEFT BY 255 PLACES.
* IF gd_buffer IS INITIAL.
* EXIT.
* ENDIF.
* ENDDO.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = 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 NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
How to Convert internal table data into text output and send mail in ABAP
Hi All,
Good Morning.
Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
But thought of doing it without excel.
I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!. Instead I want to send this output to User's mails as Normal mail body with No attachments.
Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
Best Regards
Dileep VThere's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
notice we use gt_text as "mail body"
TRY.
* -------- create persistent send request ------------------------
gv_send_request = cl_bcs=>create_persistent( ).
* -------- create and set document -------------------------------
* create text to be sent
wa_line = text-001.
APPEND wa_line TO gt_text.
CLEAR wa_line.
APPEND wa_line TO gt_text.
LOOP AT gt_fail ASSIGNING <fs_fail>.
MOVE <fs_fail>-retry_count TO gv_count.
CONCATENATE text-002
<fs_fail>-setting_id
text-003
gv_count
INTO wa_line SEPARATED BY space.
APPEND wa_line TO gt_text.
CLEAR wa_line.
ENDLOOP.
APPEND wa_line TO gt_text.
wa_line = text-007.
APPEND wa_line TO gt_text.
* create actual document
gv_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = gt_text
i_length = '12'
i_subject = 'Failed Precalculation Settings!' ).
* add document to send request
CALL METHOD gv_send_request->set_document( gv_document ).
* --------- set sender -------------------------------------------
gv_sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD gv_send_request->set_sender
EXPORTING
i_sender = gv_sender.
* --------- add recipient (e-mail address) -----------------------
LOOP AT s_email INTO wa_email.
MOVE wa_email-low TO gv_email.
gv_recipient = cl_cam_address_bcs=>create_internet_address(
gv_email ).
CALL METHOD gv_send_request->add_recipient
EXPORTING
i_recipient = gv_recipient
i_express = 'X'.
ENDLOOP.
* ---------- set to send immediately -----------------------------
CALL METHOD gv_send_request->set_send_immediately( 'X' ).
* ---------- send document ---------------------------------------
CALL METHOD gv_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = gv_sent_to_all ).
IF gv_sent_to_all = 'X'.
WRITE text-004.
ENDIF.
COMMIT WORK.
* exception handling
CATCH cx_bcs INTO gv_bcs_exception.
WRITE: text-005.
WRITE: text-006, gv_bcs_exception->error_type.
EXIT.
ENDTRY.
with the following declarations
* TABLES *
TABLES:
adr6,
rsr_prec_sett.
* INTERNAL TABLES & WORK AREAS *
DATA:
gt_fail TYPE SORTED TABLE OF rsr_prec_sett
WITH UNIQUE KEY setting_id run_date,
gt_text TYPE bcsy_text,
wa_fail LIKE LINE OF gt_fail,
wa_line(90) TYPE c.
FIELD-SYMBOLS:
<fs_fail> LIKE LINE OF gt_fail.
* VARIABLES *
DATA:
gv_count(4) TYPE n,
gv_send_request TYPE REF TO cl_bcs,
gv_document TYPE REF TO cl_document_bcs,
gv_sender TYPE REF TO cl_sapuser_bcs,
gv_recipient TYPE REF TO if_recipient_bcs,
gv_email TYPE adr6-smtp_addr,
gv_bcs_exception TYPE REF TO cx_bcs,
gv_sent_to_all TYPE os_boolean.
* SELECTION-SCREEN *
SELECT-OPTIONS:
s_email FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
DATA:
wa_email LIKE LINE OF s_email. -
How to paas internal table value
how to pass internal table first value to a variable plz help me
Hi dulla anjan prasad
You can use the LOOP statement to process special loops for any internal table.
LOOP AT itab result condition.
statement block
ENDLOOP.
This reads the lines of the table one by one as specified in the result part of the LOOP statement. You can then process them in the statements within the LOOP - ENDLOOP control structure. You can either run the loop for all entries in the internal table, or restrict the number of lines read by specifying a condition. Control level processing is allowed within the loop.
The sequence in which the lines are processed depends on the table type:
· Standard tables and sorted tables
The lines are processed according to the linear index. Within the processing block, the system field sy-tabix contains the index of the current line.
· Hashed tables
As long as the table has not been sorted, the lines are processed in the order in which you added them to the table. Within the processing block, the system field sy-tabix is always 0.
You can nest LOOP blocks. When you leave the loop, sy-tabix has the same value as when you entered it. After the ENDLOOP statement, sy-subrc is zero if at least one table entry was processed. Otherwise, it is 4.
The loop may not contain any operations on entire internal tables that change the table. However, you should remember that even saving a global internal table with the LOCAL statement in a procedure is a change operation on the entire table, since it exchanges the table contents. When you call procedures within loops, you should therefore check that it does not change the entire internal table. If you change the table, the loop can no longer work properly.
If you insert or delete a table entry within a loop pass, it is taken into account in subsequent loop passes as follows:
· If you insert a line after the current line, it will be processed in a subsequent loop pass.
· If you delete a line after the current line, it will not be processed in a subsequent loop pass.
· If you insert a line before or at the current line, the internal loop counter will be increased accordingly.
· If you delete a line before or at the current line, the internal loop counter will be decreased accordingly.
If this information is usefull plz do reward points....
Message was edited by:
ARUN -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
How to convert Internal Table to Cluster Table ?
How to convert Internal Table to Cluster Table ?
Use :
EXPORT itab TO DATABASE dbtab(ar) ID key.
<i>EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key.
Additions:
1. ... = f (for each field you want to export)
2. ... FROM f (for each field you want to export)
3. ... CLIENT g before ID key )
4. ... USING form
5. ... FROM wa (as last addition or after dbtab(ar))
In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Implicit field names not allowed with clusters and Table work areas not allowed.
Effect
Stores a data cluster in database table dbtab. The specified objects obj1 ... objn (fields, structures, or tables) are stored as a single cluster in the database table dbtab.
The specified database table dbtab must have a standard structure.
The database table dbtab is divided into various logically-related sections (ar, two-character name).
You can export a collection of data objects (a data cluster) to a part of the database using a key (field key).
You can import individual data objects from this collection using the IMPORT statement.
Notes
In classes, you must always assign explicit names to the data objects you want to export, that is, you must use either addition 1 or addition 2.
In classes, you must always specify the work area explicitly, that is, addition 5 is obligatory.
The table dbtab that appears after DATABAE must be declared under TABLES (except in addition 5).
You cannot export the header lines of internal tables. If you specify the name of an internal table with header line, the system always exports the body of the table.
You cannot export data, object, or interface references.
The data is stored in the database, and is consequently not actually stored until a database commit occurs (see LUW). Until this point, you can undo all of your changes using a database rollback (see Programming Transactions).
Example
Exporting two fields and an internal table to the database table INDX:
TABLES INDX.
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4), F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 2,
WA_INDX TYPE INDX.
Fill the data fields before CLUSTR
before the actual export
INDX-AEDAT = SY-DATUM.
INDX-USERA = SY-UNAME.
Export der Daten.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.
</i>
Regards -
How to access internal table data from webdynpro to Flex application.
Hi Connoisseur
The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
i tried to do pass internal table value to flex-datagrid.but its not work.
i would like to know
1.how to access internal table data from webdynpro to Flex application.
2.how to pass the internal table to flex-datagrid.
2.how to pass dynamically in ADOBE flex.
3. how to do Flex is receiving the wd context data?
4. how can we update WD context with FLEX data.
Ple give me sample example and step by step procedure.
Regards
laxmikanthHi Laxmikanth,
Please refer this...
Flash island: update complex type from flex
Cheers..
kris. -
How to pass internal table to method of class
Hi all,
I am new to abap objects, i want to pass one internal table to class.
i am trying in this way.
class c1 definition.
method get_material importing t_stpo type any table
exporting t_mast type any table.
endmethod.
endclass.
class c1 implementation.
method get_material.
select f1 f2 f3 from <tab> into table t_mast
for all entries in t_stpo
where stlnr = t_stpo-stlnr.
endmethod.
endclass.
ERROR:
"stlnr" is not available
if i use this way. its not giing error.
class c1 definition.
method get_material exporting t_mast type any table.
endmethod.
endclass.
class c1 implementation.
method get_material.
select f1 f2 f3 from <tab> into table t_mast
for all entries in it_stpo
where stlnr = it_stpo-stlnr.
endmethod.
endclass.
how to pass internal table with some specific reference may be using like or type <it_xxxx>
thanksTry this.
TYPES : BEGIN OF ty_stpo,
stlnr TYPE stpo-stlnr,
idnrk TYPE stpo-idnrk,
menge TYPE stpo-menge,
END OF ty_stpo,
BEGIN OF ty_mast,
matnr TYPE mast-matnr,
werks TYPE mast-werks,
stlnr TYPE mast-stlnr,
END OF ty_mast,
tt_stpo TYPE TABLE OF ty_stpo,
tt_mast TYPE TABLE OF ty_mast.
DATA : it_stpo TYPE tt_stpo,
it_mast TYPE tt_mast.
* CLASS c1 DEFINITION
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS : get_bom_numbers EXPORTING ex_stpo type tt_stpo,
get_parent_material IMPORTING im_stpo TYPE tt_stpo
EXPORTING ex_mast TYPE tt_mast.
endclass.
* CLASS c1 IMPLEMENTATION
CLASS c1 IMPLEMENTATION.
METHOD get_bom_numbers.
ENDMETHOD. "get_bom_numbers
METHOD get_parent_material.
ENDMETHOD. "get_parent_material
START-OF-SELECTION.
DATA : obj TYPE REF TO c1.
CREATE OBJECT obj.
CALL METHOD obj->get_bom_numbers
IMPORTING
t_stpo = it_stpo.
CALL METHOD obj->get_parent_material
EXPORTING
im_stpo = it_stpo
IMPORTING
ex_mast = it_mast.
Regards,
Rich Heilman -
How to Populate Internal table data to Table Control in a Report Program
Dear All,
How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
Thanks in Advance,
Joseph ReddyIf you want to use a table control, you will need to create a screen.
In your report....
start-of-selection.
perform get_data. " Get all your data here
call screen 100. " Now present to the user.
Double click on the "100" in your call screen statement. This will forward navigate you to the screen. If you have not created it yet, it will ask you if you want to create it, say yes. Go into screen painter or layout of the screen. Use the table control wizard to help you along the process. It will write the code for you. Since it is an output only table control, it will be really easy with not a lot of code.
A better way to present the data to the user would be to give it in a ALV grid. If you want to go that way, it is a lot easier. Here is a sample of the ALV function module. You don't even have to create a screen.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
* Get_Data
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
* WRITE_REPORT
form write_report.
perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
endform.
Regards,
Rich Heilman -
How to check the tables we have created in JDBC??
I have created a table called COFFEE2 in a datasource called temp which is in SQL server...How to check the table values??
i went into administrative tools and odbc cource then i could see the data source i have created but how to see the table??
Can anyone help??
thanxHmm.. not sure that I understand the problem.
Call getConnection on the DataSource, and then execute the select query on the connection.
Kaj -
How to check with table for cursor..?
How to check with table for cursor..?
Here I have Table temp_final_plan
Here i want to update if already exit...below is the procedure....
CREATE OR REPLACE PROCEDURE spu_final_profit_plan
AS
-- Constant declarations
ln_errnum number := 0;
-- Variable declarations
ls_errmsg app_errors.err_msg%TYPE;
ls_appmsg app_errors.app_msg%TYPE;
ls_appid app_errors.app_id%TYPE;
-- Cursor declaration for final_update_el
CURSOR cur_final_update_el IS
select '910' ent,
'9127316' center,
post_acct,
sum(avg_mtd_01) sum_avg_mtd_01,
sum(avg_mtd_02) sum_avg_mtd_02,
sum(avg_ytd_01) sum_avg_ytd_01,
sum(avg_ytd_02) sum_avg_ytd_02
from mon_act_cypy
where rec_type = 'A'
and sum_flag = 'D'
and yr = '2008'
and substr(ctr_or_hier, 1, 2) = 'el'
and ent || sub_ent in
(select ent || sub_ent
from ent_ref
where roll_ent || roll_sub_ent = '999100')
group by post_acct
having sum(avg_mtd_01) <> 0
or sum(avg_mtd_02) <> 0
or sum(avg_ytd_01) <> 0
or sum(avg_ytd_02) <> 0;
-- Cursor declaration for final_update
CURSOR cur_final_update IS
select b.plan_ent b_plan_ent,
b.plan_ctr b_plan_ctr,
a.post_acct a_post_acct,
sum(a.avg_mtd_01) sum_avg_mtd_01,
sum(a.avg_mtd_02) sum_avg_mtd_02,
sum(a.avg_ytd_01) sum_ytd_mtd_01,
sum(a.avg_ytd_02) sum_ytd_mtd_02
from mon_act_cypy a,
plan_unit_tbl b
where a.ent || a.ctr_or_hier = b.ent || b.ctr_or_hier
and a.rec_type = 'A'
and a.sum_flag = 'D'
and a.yr = '2008'
and b.hier_tbl_num = '001'
and a.ent || a.sub_ent in
(select ent || sub_ent
from ent_ref
where roll_ent || roll_sub_ent = '999100')
group by b.plan_ent, b.plan_ctr, a.post_acct
having sum(a.avg_mtd_01) <> 0
or sum(a.avg_mtd_02) <> 0
or sum(a.avg_ytd_01) <> 0
or sum(a.avg_ytd_02) <> 0;
-- Begin the procedure body
BEGIN
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update_el IN cur_final_update_el
LOOP
EXIT WHEN rec_final_update_el%NOTFOUND;
IF rec_final_update_el. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,
WHERE ent = rec_final_update_el.ent
AND center = rec_final_update_el.center
AND post_acct = rec_final_update_el.post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
rec_final_update_el.center,
rec_final_update_el.post_acct,
rec_final_update_el.sum_avg_mtd_01,
rec_final_update_el.sum_avg_mtd_02,
rec_final_update_el.sum_avg_ytd_01,
rec_final_update_el.sum_avg_ytd_02);
END IF;
END LOOP;
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update IN cur_final_update
LOOP
EXIT WHEN rec_final_update%NOTFOUND;
IF rec_final_update. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update.sum_avg_ytd_02,
WHERE ent = rec_final_update.b_plan_ent
AND center = rec_final_update.b_plan_ctr
AND post_acct = rec_final_update.a_post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update.b_plan_ent,
rec_final_update.b_plan_ctr,
rec_final_update.a_post_acct,
rec_final_update.sum_avg_mtd_01,
rec_final_update.sum_avg_mtd_02,
rec_final_update.sum_avg_ytd_01,
rec_final_update.sum_avg_ytd_02);
END IF;
END LOOP;
-- EXCEPTION handling section
EXCEPTION
-- Fire OTHERS Exception case by default
WHEN OTHERS THEN
-- ROLL BACK Transaction, if any failure
ROLLBACK;
ln_errnum := SQLCODE;
ls_errmsg := SUBSTR(SQLERRM, 1, 100);
-- Log the ERRORS into APP_ERRORS table using SPU_LOG_ERRORS procedure
spu_log_errors(ln_errnum, ls_errmsg, ls_appid, ls_appmsg);
-- End of the stored procedure
END spu_final_profit_plan;
[\pre]I'm not sure what you mean by, 'How to check with table for cursor..?' but I'll offer a comment on your Code Snippet. I think you want to know how to check if a record exists so you know if you need to perform an INSERT or an UPDATE.
Here is a snippet of your code. I'll put my comments in "Comment" style in your code.
-- Insert / Update final profit plan for final_update query using cursor
FOR rec_final_update_el IN cur_final_update_el
LOOP
/* There is no need to test for %NOTFOUND since you are using Cursor FOR Loop!
** This construct automatically exits when the last record is processed. */
EXIT WHEN rec_final_update_el%NOTFOUND;
/* Is this where you would like to know how to Check if the record already exist??
** I asked this because, 'rec_final_update_el.' is not valid syntax. Are you looking for
** an Cursor Attribute or Method you can check here?
** I would suggest a Primary Key or Unique Index on ENT, CENTER, and POST_ACCT
** on the TEMP_FINAL_PLAN table. Then simply perform an INSERT and code an
** Exception to UPDATE when you get a DUP_VAL_ON_INDEX exception. Otherwise,
** you will need to simply run an Implicit or Explicit Cursor to test if the row exists and
** use this return value to determine if you should INSERT or UPDATE. */
IF rec_final_update_el. THEN
UPDATE temp_final_plan
SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,
sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,
sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,
WHERE ent = rec_final_update_el.ent
AND center = rec_final_update_el.center
AND post_acct = rec_final_update_el.post_acct;
ELSE
INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
rec_final_update_el.center,
rec_final_update_el.post_acct,
rec_final_update_el.sum_avg_mtd_01,
rec_final_update_el.sum_avg_mtd_02,
rec_final_update_el.sum_avg_ytd_01,
rec_final_update_el.sum_avg_ytd_02);
END IF;
END LOOP;I hope I've answered your question, but if I haven't please provide more details so we can better understand your request.
Craig... -
How to check Reconcilliation has happened or not for a payment document
Hi,
How to check Reconcilliation has happened or not for a payment document? Payment doc ABCDEF was created on 2nd. Now i am not sure whethr RECON has happend ot not
Please help.Dear,
If you have made payment to vendor and want to know whether reconciliation happened or not then check if this document exist in table BSIK then reconciliation has not been done.
Regards,
Chintan Joshi. -
How to check small table scan full table scan if we will use index in where clause.
How to check small table scan full table scan if i will use index column in where clause.
Is there example link there i can test small table scan full table if index is used in where clause.Use explain plan on your statement or set autotrace traceonly in your SQL*Plus session followed by the SQL you are testing.
For example
SQL> set autotrace traceonly
SQL> select *
2 from XXX
3 where id='fga';
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=13 Card=1 Bytes=16
5)
1 0 PARTITION RANGE (ALL) (Cost=13 Card=1 Bytes=165)
2 1 TABLE ACCESS (FULL) OF 'XXX' (TABLE) (Cost=13 Card
=1 Bytes=165)
Statistics
1 recursive calls
0 db block gets
1561 consistent gets
540 physical reads
0 redo size
1864 bytes sent via SQL*Net to client
333 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed -
How to write internal table data vertically . Records vertically.
Hi pals,
How to write internal table records vertically .
suppose the records are
a1 a2 a3
b1 b2 b3
we need to display
a1 b1
a2 b2
a3 b3
Thanks in advance.
balaji.TJust check the code
DATA: BEGIN OF itab OCCURS 0,
f1 TYPE i,
f2 TYPE i,
f3 TYPE i,
END OF itab.
DATA pos TYPE i.
"Define your lines where you want to print here...
DATA line1 TYPE i VALUE 10.
DATA line2 TYPE i VALUE 12.
DATA line3 TYPE i VALUE 14.
itab-f1 = '1'.
itab-f2 = '10'.
itab-f3 = '100'.
APPEND itab.
itab-f1 = '2'.
itab-f2 = '20'.
itab-f3 = '200'.
APPEND itab.
itab-f1 = '3'.
itab-f2 = '30'.
itab-f3 = '300'.
APPEND itab.
itab-f1 = '4'.
itab-f2 = '40'.
itab-f3 = '400'.
APPEND itab.
loop at itab.
write : / itab-f1,itab-f2,itab-f3.
endloop.
LOOP AT itab.
pos = pos + 10.
SKIP TO LINE line1.
POSITION pos.
WRITE itab-f1.
SKIP TO LINE line2.
POSITION pos.
WRITE itab-f2.
SKIP TO LINE line3.
POSITION pos.
WRITE itab-f3.
ENDLOOP.
Maybe you are looking for
-
I would like to copy my iPhoto (9.4.1) library from my Mac Pro (10.7.5) to a Macbook Pro (10.7.5). Can I drag the iPhoto Library from the Pictures folder to Air Drop and send them to the MacBook? If I then move that to the Pictures folder on the MacB
-
Designing additional fields for CATS
Hi, I want to add additional fields to CATSDB , but my question is whether the field name can be modified as per requirement and whether we can have list of values against these fields ? Regards, Ayesha
-
Hi, this is a bug concerning Java3D for linux (problem not seen under windows (!!) ) from demo installed with the jdk : in directory OffScreenCanvas3D, in file PrintFromButton.java here is some code which works : GraphicsConfiguration config = Simple
-
CS4 - not showing sharp pictures
When have selected a number of pictures in Bridge and showing them i fullscreen (ctrl-l). Bridge is not showing them shap - more as a jpeg in low res. If I do a zoom on the picture then wait for a few seconds, it gets as expected but when zoom out it
-
Reading multiple PWM using a single counter
Hi everyone. Not really sure if this goes in digital i/o or counter/timer but here it is. I'm trying to design a system where i send out an signal from a transducer, and have other transducer measure the delta t between the 1st transducer emitting th