"A peak into ABAP"
Hi Gurus!
Since its inevitable to overlook the application part, as I have a series of questions running across
1. What is the difference between a routine and a requirement?
2. What is ABAP debugging? How is it carried out?
3. What is the client specific data?
4. Can a standard user exits be modified by ABAPers?
5. Can we create a user exit? If yes, how?
6. What are the SD related reports we can generated with help of ABAP?
7. What is ABAP query?
8. There are certain fields which turn into display mode once the sales document is created, which we can see them in order document change mode. How can I change the field status? last time some body said it can be done using "transaction varient". suppose if want the "payment terms" at Item level, shipping tab page to be shown in change mode in [VA02]. how? Please explain steps in detail.
All respondents will be rewarded generously.
Thanks in Advance
KV
1. What is the difference between a routine and a requirement?
Routines is generic words which include all the routines defined in VOFM it includes AltCBV, AltCTY..etc, Requirement, it is piece of Code which needs to be fulfilled to consider further processing, for e.g. Requirement 2 checks pricing is activated or not, if it is not activated in item category, it will show requirement is not fulfilled
Pricing is turned on in item category configuration (TVAP)
form kobed_002.
sy-subrc = 4.
if komp-kposn ne 0.
check: komp-prsfd ca 'BX'.
check: komp-kznep = space.
endif.
sy-subrc = 0.
endform.
Prestep
form kobev_002.
sy-subrc = 0.
endform.
2. What is ABAP debugging? How is it carried out?
There are many links you can find
at command prompt put /h and debug will start you can explore your self
http://www.saplinks.net/?p=8
3. What is the client specific data?
Client Specific Data, in table first field is client CLNT , Any configuration in this data will not effect other clients in SPRO
you can view in Additional Information->Technical Data-> Client Specific
4. Can a standard user exits be modified by ABAPers?
Yes but Access Key is required , which is available from SAP
5. Can we create a user exit? If yes, how?
Here we mean whom? user exit can be created, but again access key is required from SAP
6. What are the SD related reports we can generated with help of ABAP?
list of invoice, delivery, sales orders..etc
7. What is ABAP query?
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4662456e-0701-0010-3fb3-f0630b6c17df
8. There are certain fields which turn into display mode once the sales document is created, which we can see them in order document change mode. How can I change the field status? last time some body said it can be done using "transaction varient". suppose if want the "payment terms" at Item level, shipping tab page to be shown in change mode in VA02. how? Please explain steps in detail.
Find the tutorial
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/transaction%2bvariant%2b-%2ba%2bstep%2bby%2bstep%2bguide%2bfor%2bcreation
Regards
Jitesh
Similar Messages
-
Simple Transformation to deserialize an XML file into ABAP data structures?
I'm attempting to write my first simple transformation to deserialize
an XML file into ABAP data structures and I have a few questions.
My simple transformation contains code like the following
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:pp="http://www.sap.com/abapxml/types/defined" >
<tt:type name="REPORT" line-type="?">
<tt:node name="COMPANY_ID" type="C" length="10" />
<tt:node name="JOB_ID" type="C" length="20" />
<tt:node name="TYPE_CSV" type="C" length="1" />
<tt:node name="TYPE_XLS" type="C" length="1" />
<tt:node name="TYPE_PDF" type="C" length="1" />
<tt:node name="IS_NEW" type="C" length="1" />
</tt:type>
<tt:root name="ROOT2" type="pp:REPORT" />
<QueryResponse>
<tt:loop ref="ROOT2" name="line">
<QueryResponseRow>
<CompanyID>
<tt:value ref="$line.COMPANY_ID" />
</CompanyID>
<JobID>
<tt:value ref="$line.JOB_ID" />
</JobID>
<ExportTypes>
<tt:loop>
<ExportType>
I don't know what to do here (see item 3, below)
</ExportType>
</tt:loop>
</ExportTypes>
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
</QueryResponseRow>
</tt:loop>
</QueryResponse>
</tt:loop>
1. In a DTD, an element can be designated as occurring zero or one
time, zero or more times, or one or more times. How do I write the
simple transformation to accommodate these possibilities?
2. In trying to accommodate the "zero or more times" case, I am trying
to use the <tt:loop> instruction. It occurs several layers deep in the
XML hierarchy, but at the top level of the ABAP table. The internal
table has a structure defined in the ABAP program, not in the data
dictionary. In the simple transformation, I used <tt:type> and
<tt:node> to define the structure of the internal table and then
tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
can occur zero or more times. But every variation I try seems to get
different errors. Can anyone supply a working example of this?
3. Among the fields in the internal table, I've defined three
one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
XML file, I expect zero to three elements of the form
<ExportType exporttype='csv' />
<ExportType exporttype='xls' />
<ExportType exporttype='pdf' />
I want to set field TYPE_CSV = 'X' if I find an ExportType element
with its exporttype attribute set to 'csv'. I want to set field
TYPE_XLS = 'X' if I find an ExportType element with its exporttype
attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
an ExportType element with its exporttype attribute set to 'pdf'. How
can I do that?
4. For an element that has a value like
<ErrorCode>123</ErrorCode>
in the simple transformation, the sequence
<ErrorCode> <tt:value ref="ROOT1.CODE" /> </ErrorCode>
seems to work just fine.
I have other situations where the XML reads
<IsNew value='true' />
I wanted to write
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
but I'm afraid that the <tt:value> fails to deal with the fact that in
the XML file the value is being passed as the value of an attribute
(named "value"), rather than the value of the element itself. How do
you handle this?Try this code below:
data l_xml_table2 type table of xml_line with header line.
W_filename - This is a Path.
if w_filename(02) = '
open dataset w_filename for output in binary mode.
if sy-subrc = 0.
l_xml_table2[] = l_xml_table[].
loop at l_xml_table2.
transfer l_xml_table2 to w_filename.
endloop.
endif.
close dataset w_filename.
else.
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = l_xml_size
filename = w_filename
filetype = 'BIN'
changing
data_tab = l_xml_table
exceptions
others = 24.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. -
Hello folks,
I've been struggling and I need to figure out how to read a field from an XML field into ABAP. I'm writing this method and I need to call this field from my XML file. Can you guys please give me suggestions? Please advise. I will appreciate your time. Thanks in advance.
Ol.*& Report z_xit_xml_check
report z_xit_xml_check.
class cl_ixml definition load.
type-pools: ixml.
types: begin of t_xml_line,
data(256) type x,
end of t_xml_line,
begin of tsfixml,
data(1024) type c,
end of tsfixml.
data: l_ixml type ref to if_ixml,
l_streamfactory type ref to if_ixml_stream_factory,
l_parser type ref to if_ixml_parser,
l_istream type ref to if_ixml_istream,
l_document type ref to if_ixml_document,
l_node type ref to if_ixml_node,
l_xmldata type string.
data: l_elem type ref to if_ixml_element,
l_root_node type ref to if_ixml_node,
l_next_node type ref to if_ixml_node,
l_name type string,
l_iterator type ref to if_ixml_node_iterator.
data: l_xml_table type table of t_xml_line,
l_xml_line type t_xml_line,
l_xml_table_size type i.
data: l_filename type string.
parameters: pa_file type char1024 default
'd:\joao\desenvolvimentos\fi\fact\teste.xml'.
Validation of XML file: Only DTD included in xml document is supported
parameters: pa_val type char1 as checkbox.
start-of-selection.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
perform get_xml_table changing l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table =
l_xml_table
size =
l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
if pa_val eq 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
endif.
Parse the stream
if l_parser->parse( ) ne 0.
if l_parser->num_errors( ) ne 0.
data: parseerror type ref to if_ixml_parse_error,
str type string,
i type i,
count type i,
index type i.
count = l_parser->num_errors( ).
write: count, ' parse errors have occured:'.
index = 0.
while index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
write: 'line: ', i.
i = parseerror->get_column( ).
write: 'column: ', i.
str = parseerror->get_reason( ).
write: str.
index = index + 1.
endwhile.
endif.
endif.
Process the document
if l_parser->is_dom_generating( ) eq 'X'.
perform process_dom using l_document.
endif.
*& Form get_xml_table
form get_xml_table changing l_xml_table_size type i
l_xml_table type standard table.
Local variable declaration
data: l_len type i,
l_len2 type i,
l_tab type tsfixml,
l_content type string,
l_str1 type string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab type table of string.
l_filename = pa_file.
upload a file from the client's workstation
call method cl_gui_frontend_services=>gui_upload
exporting
filename = l_filename
filetype = 'BIN'
importing
filelength = l_xml_table_size
changing
data_tab = l_xml_table
exceptions
others = 19.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
*replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
*IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
endform. "get_xml_table
*& Form process_dom
form process_dom using document type ref to if_ixml_document.
data: node type ref to if_ixml_node,
iterator type ref to if_ixml_node_iterator,
nodemap type ref to if_ixml_named_node_map,
attr type ref to if_ixml_node,
name type string,
prefix type string,
value type string,
indent type i,
count type i,
index type i.
data: name2 type string,
name_root type string,
node_parent type ref to if_ixml_node,
node_root type ref to if_ixml_node,
num_children type i.
node ?= document.
check not node is initial.
uline.
write: /.
write: /' DOM-TREE'.
write: /.
if node is initial. exit. endif.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
while not node is initial.
indent = node->get_height( ) * 2.
indent = indent + 20.
num_children = node->num_children( ).
case node->get_type( ).
when if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
node_root = node->get_root( ).
name_root = node_root->get_name( ).
write: / 'ELEMENT :'.
write: at indent name color col_positive inverse.
write: 'NUM_CHILDREN:', num_children.
write: 'ROOT:', name_root.
node_parent = node->get_parent( ).
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
if not nodemap is initial.
attributes
count = nodemap->get_length( ).
do count times.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
write: / 'ATTRIBUTE:'.
write: at indent name color col_heading inverse, '=',
value color col_total inverse.
enddo.
endif.
when if_ixml_node=>co_node_text or
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
write: / 'VALUE :'.
mjprocha
node_parent = node->get_parent( ).
write: at indent value color col_group inverse.
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
endcase.
advance to next node
node = iterator->get_next( ).
endwhile.
endform. "process_dom -
Convert XML file into ABAP Query
Hi All,
Can we capture a XML file generated from a Non-SAP system in SAP system and convert into ABAP Query to retreive Data from DB and post it back as a XML query to the same Non-SAP system using a Middleware. Can this process be done in cache memory level itself instead of saving in DB.
If it is possible pls do tell the procedure and steps to be followed.
Suggestion and Help will be much Appreciated
Thanks & Regds.
RameshHi check these blogs....
<a href="/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach:///people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
<a href="/people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6:///people/tobias.trapp/blog/2005/12/08/xml-processing-in-abap--part-6 -
How to get the material list displayed in CU50 transaction into ABAP report
How to get the 'KMAT" type material list displayed in CU50 transaction into ABAP report?
I am getting the entire BOM when i am using the FM CS_BOM_EXPL_MAT_V2 in to the table in the report.
But I want only the material list displayed in CU50.Hi,
Could you please tell us how you found a solution to your problem?
Thanks & regards
Hassan -
Receive CSV attachment via Mail Adapter and process into ABAP proxy
Hi,
I have the following scenario:
1. Receive e-mail with CSV attachment
2. Process through Mail adapter (KeepAttachments = Yes in order to retain the CSV attachment)
3. Receive into ABAP proxy (with CSV attachment)
The next step is to read the attachment in the ABAP proxy and process the CSV attachment data into CRM.
The CSV attachment contains the data I wish to process - the body of the e-mail will not contain this information.
The problem I have is reading the attachment data in the proxy - not sure of the methods/class to call - anyone got any ideas ?
Another question is this the best way to do this and process the CSV attachment data ?
I know I could use the PayloadSwapBean to switch the payload to the attachment but then I am stumped with how the attachment is processed through PI 7.1 - how do you transform the CSV format payload into XML so PI will be able to process it through mapping.
Either option is viable - an answer to either question would be great.
1. How do you read the attachment data in an inbound ABAP proxy ?
2. How do you transform the CSV attachment data after the PayloadSwapBean from CSV to XML ?
Kind regards
Colin.Hi Colin
As you are not interested in processing the body of email. Swap the payload to the attachment using the PayloadSwapBean
Change the content from CSV to XML using MessageTransformBean. Now pass this information to Proxy. You dont need to deal with attachments in proxy.
It is not possible to read attachment in server proxy because the class and interface you create will not have data type which can refer to an attachment processing interface in ABAP.
Thanks
Gaurav -
How to read Filter selection variable values into ABAP code
HI IP Gurus,
Requierement: In my filter characterstics, i have assigned variables, which use will enter when running th e planning sequence.
so variable values entered by user , i would like to get those values into ABAP code and pass them to some function module.
SO please give me step by step detail how to achive this.
MY understanding use the below method . but not sure how to proceed.Please let me know abap code to get values.
GET_TAB_PARAM_DATA_SEL and GET_PARAM_DATA_SEL.
Please help me.
Thanks in advance.Will Assign points
SaniaHi Srinivas,
So In RSPLF1 , in paramters tab, Do i have create structure(str1) and then create component Data selection (Dtsel1) under str1(what setting i have to do here, where should i enter variable value and do i need to give info object name and how do it in code.i tried to following example, not able to get any values in tab_sel .
It will be great, if you could explain in detail.
other thing i found out is in Initialization method i can read i_t_data_charsel table values , where it contains filter slected values.but could not pass these values to execute method
Is there is any way that i can pass values from init method to execute method.
A tabular structured parameter with name "MY_TABSTRUC" is defined for the function type. "MY_TABSTRUC" consists of the two parameter components "MY_ELEM" and "MY_DATASEL". You access the parameter values as follows:
DATA: TAB_PARAM_STRUC TYPE RSPLFA_T_PARAM_STRUC,
REF_PARAM_STRUC TYPE REF TO IF_RSPLFA_PARAM_STRUC,
REF_PARAM_ELEM TYPE REF TO IF_RSPLFA_PARAM_ELEM,
REF_PARAM_DATASEL TYPE REF TO IF_RSPLFA_PARAM_DATESEL,
L_VAL(20) TYPE C,
TAB_SEL TYPE RSPLF_T_CHARSEL.
get table of parameter MY_TABSTRUC:
TAB_PARAM_STRUC = I_R_PARAM_SET->GET_TAB_PARAM_STRUC( 'MY_TABSTRUC' ).
process all lines:
LOOP AT TAB_PARAM_STRUC into REF_PARAM_STRUC.
get component MY_ELEM:
REF_PARAM_ELEM = REF_PARAM_STRUC->GET_COMP_ELEM( 'MY_ELEM' ).
get internal value of MY_ELEM:
REF_PARAM_ELEM->GET_VALUE( IMPORTING E_VALUE = L_VAL ).
get component MY_DATASEL:
REF_PARAM_DATASEL = REF_PARAM_STRUC->GET_COMP_DATA_SEL( 'MY_DATASEL' ).
get data selection table of MY_DATASEL:
TAB_SEL = REF_PARAM_DATASEL->GET_T_SEL( ).
ENDLOOP.
Thanks in Advance..please help me -
Hi,
Is there any way to upload an XML file into ABAP WD?
I just saw a blog for Java WD.
<a href="/people/johann.marty/blog/2006/10/03/create-a-web-dynpro-tree-from-an-xml-file:///people/johann.marty/blog/2006/10/03/create-a-web-dynpro-tree-from-an-xml-file
Is there a similar facility in ABAP WD?
Regards,
Haresh.hey u can do this by using CALL Transformation id.. command..
here is the example code where i wrote this to convert it DATA to XML format...it may help u..
DATA : BEGIN OF l_xml_tab OCCURS 0,
a(100) TYPE c,
END OF l_xml_tab.
DATA : xml_out TYPE string .
DATA : lw_xml_tab LIKE LINE OF l_xml_tab.
XML
CALL TRANSFORMATION id "('ID')
SOURCE tab = gt_outtab[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = l_xml_tab.
OPEN DATASET p_lgfil1 FOR OUTPUT IN BINARY MODE.
LOOP AT l_xml_tab INTO lw_xml_tab.
TRANSFER lw_xml_tab TO p_lgfil1.
ENDLOOP.
CLOSE DATASET p_lgfil1. -
PI sheet Converted from Browser into abap based PI sheet
Hi,
i want my PI sheet to convert it from browser based PI sheet into abap based pi sheet.could any suggest how to convert browser based pi into abap based pi .
thanks
VikranthDid not got the answer, clossing the threat.
-
Is there any way to embed VIM into abap editor on windows.
I know that it is possible to embed Vim in linux version of SAP gui.
Any one has ideas?Is there any way to embed VIM into abap editor on windows.
Haven't heard about this one, but since the idea sounded pretty good to me I tried to find any evidence in the web. However, at least I noticed that the Eclipse-VIM integration seems to be working now. So thanks for the posting and getting things rolling...
I know that it is possible to embed Vim in linux version of SAP gui.
Not sure what you mean by linux version of SAPgui. Basically the only SAPgui version that exists for Linux is the Java GUI (assuming that we're not talking about trying to run the Windows SAPgui in Wine environment). I personally doubt that such a thing exists, but if you know any details, please share your knowledge or links...
VIM has a socket interface which allows in theory IDE's to attach (:help netbeans), but haven't heard that anything exists in the SAP world to utilize this. Maybe there's other ways, so let us hear what you know...
Thanks, harald -
Getting Data from Maintenance view V001N into ABAP program
Hello Experts,
I have to fetch data from the maintenance view V001N in my ABAP program. I have used select statement in my program but I am getting a syntax error 'V001N is not defined in the ABAP Dictionary as a table, projection view or database view. '. V001N is a Maintenance view.
Can anybody help me out how to get the data from that maintenance view into the internal table of my ABAP program.
Regards.Sunil,
check these threads
https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6074746
https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6088233
so query on the tables which are used in the view
Thanks
Bala Duvvuri -
Read SOAP envelope into ABAP using XSLT?
Hello,
I have another problem here and this is really driving me nuts - I just don't get it to work.
As a reply to a web-service I call I get the following xml file. All I need is an xslt that gets me errorCode and errorDescription into an ABAP structure...
file:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<mit:rgo xmlns:mit="http://myurl.com"><mit:TECHNICALHEADER><mit:errorCode>A1014</mit:errorCode><mit:errorDescription>Unable to perform operation</mit:errorDescription><mit:password/><mit:user/><mit:applicationKey/></mit:TECHNICALHEADER><mit:file_creation_date>2005-09-06</mit:file_creation_date><mit:file_creation_time>15:06:33.0</mit:file_creation_time><mit:registration><mit:order_nr>DE999TEST</mit:order_nr><mit:vin>XXXXXXXXXXXXXXX04</mit:vin></mit:registration></mit:rgo> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
my corresponding XSLT is:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mit=
"http://myurl.com" xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap>
<asx:values>
<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<mit:rgo>
<mit:TECHNICALHEADER>
<ANSWER>
<mit:errorCode>
<xsl:value-of select="ERRORCODE"/>
</mit:errorCode>
<mit:errorDescription>
<xsl:value-of select="ERRORCODEDESCRIPTION"/>
</mit:errorDescription>
</ANSWER>
</mit:TECHNICALHEADER>
</mit:rgo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
What am I doing wrong or what do I need to do? I'm lost!
Thank you for your help!
Johannes.Thank you Durairaj, as a matter of fact my program is based on your post (one that you pointed me to). For whatever reason I'm not having luck figuring it out (may be just a bit of work pressure) could you please hlep me a bit more by pointing me to where in my program code/xslt I'm going wrong? I somehow feel that it could be my table structure or xslt.
I would really appreciate it!
Thanks again,
erfan. -
How to process XML into ABAP data?
Hi,
I have a string variable which content is a xml file. Then how to extract data from it into corresponding ABAP data objects like internal table or structure?
Thanks a lot!HI Long
check this code which converts xml to bap internal table using DOM
REPORT Z_XML_TO_TABLE.
TYPE-POOLS: ixml.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
l_xml_line TYPE t_xml_line,
l_xml_table_size TYPE i.
DATA: l_filename TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:\temp\orders_dtd.xml'.
Validation of XML file: Only DTD included in xml document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table =
l_xml_table
size =
l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val EQ 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
FORM get_xml_table CHANGING l_xml_table_size TYPE i
l_xml_table TYPE STANDARD TABLE.
Local variable declaration
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
upload a file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. "get_xml_table
*& Form process_dom
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE: /.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL. EXIT. ENDIF.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
advance to next node
node = iterator->get_next( ).
ENDWHILE.
ENDFORM. "process_dom
regards
kishore
reward if helpful -
Integrating Web Dynpro for ABAP into ABAP Workflow
We have a requirement to create a User Interface via Web Dynpro for ABAP, and use that information to start off a workflow, transferring the data from the Web Dynpro application into the container of the Workflow.
Also later in the workflow, we would like an approval step to invoke a Web Dynpro that displayes the data, and an approve/reject button to be pressed that feeds that data back to the Workflow.
Has anybody done this, or does anybody know how to do this? We do not have the possibilities to use CAF in this project yet.
Kind Regards,
Tony.Hi,
This is of course possible. Starting the workflow with Web Dynpro or from classic ABAP dynpro doesn't really differ. Just build your web dynpro as you would build a transaction, and from the submitting/execution phase, you just launch the workflow. Launching the workflow can be done with couple of different techniques (=function modules) and it has been discussed many times here.
Also the approval part shouldn't cause any problems. Just build an application which takes as a parameter for example the work item ID (or any other relevant parameter that you can imagine, which you can use to retrieve the needed data that you want to display). Then from the web dynpro application you can call for example a function module, which can complete the work item. Or another option is that you will raise an event (again with a function module), which your approval task is waiting for.
Once again, it isn't really that different from classic dynpro (or any other technique) - the same approaches can be utilized.
Regards,
Karri -
Integrating External Operating System Commands into ABAP program.
Hi folks,
using the transaction code sm69 it is possible to create an SAP command that's executing an operating system command.
Is it possible to integrate such an SAP command into our ABAP programs ?
How would we do so ?
Regards
ThomasHello Thomas,
We have an easier way of achieving this without declaring a command in SM69.
Try the below piece of code:
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'ls -l'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.
Replace the string in the variable 'comand' with any UNIX command.
Regards
Sabu
Maybe you are looking for
-
TS3682 Iphone cannot sync and is not recognised by computer or itunes
Iphone continually displays the symbol to connect with itunes when pluged into to a source of electricity... but Itunes doesn't recognise it and i cannot get it to sync. I have downloaded the newest version of itunes and updated my computer but still
-
Where do i get my password for logic pro x?
i bought logic pro x today and am trying to install it but its asking for my password. where can i find this password?
-
Is there a way to disable files opening with one-click?
This is driving me crazy! I thought previously the problem was "magic mouse" but now that I've gone back to my old mouse, the problem persists. If I select a file in a finder window, it opens with one click. Also, if I try to edit a file name or even
-
How to update a published Muse website on all browsers.
I've updated my Muse site, which works in safari but the updates are not made in chrome. How do I get all browsers to update my website? I'm using a mac and I've already tried inputing different "folder" options (i'm hosting with godaddy). Thank you.
-
I have created a method on using a bufferedimage to draw an image with additional shape on top of the image. But when I run it, the shape cannot display. I try to get help in this forum but still expert said the GeneralPath I created is fine, so I re