Read data based on date in internal tables
Hi Abapers,
In my zreport , i am retreving data from vbrk, vbrp into one internal table ( itab1) and retreiving data from customized table i nto internal table itab2.
itab1 contains following fields.
matnr - Material code
erdat - date ( billing date).
itab2 contains following fields.
matnr - material code.
zfromdate - from date
ztodate - to date
zstprs - material price
loop at itab1 .
endloop.
how to read particular record from itab2 ( which consists of material code with price maintaing with date range ) based on my billing document date i.e erdat
ex: material code fromdate todate price
10000 01.11.2008 20.11.2008 100.
10000 21.11.2008 30.11.2008 104
if for example in itab1 , erdat ( billing doc date is 15.11.2008 ) , how to read first record in itab2 which will fall under that date range.
please give me any suggestions, or provide sample code.
regards,
Hari priya
Hi,
Please go in this way
while selecting fileds from table into itab2
select in this way
select * from <tablename> into tabel itab2 where
matnr = itab1-matnr and
zfromdate LE erdat and
ztodate GE erdat.
Loop at itab2.
read table itab1 with key matnr = itab2-matnr.
take ur fields into internal table
endloop.
Similar Messages
-
Problem converting data in XML file to internal table data
Hi all,
I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
With the help of this blog /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
Can some one suggest how should I read the data in an internal table.
Here is my code..what changes should I make?
*& Report z_xit_xml_check
REPORT z_xit_xml_check.
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
Any help would be highly apperciated.
regards,
Jessica SamPavel Vera,
With your example i tries doing the following .....
I tried to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
I also need to collect the following tags from <Shipmentdetail>
<Shipmentdetail> has following child nodes and I need to collect them
TrackingNumber
Freight
Weight
ShipmentDate
ShipmentMethod
Need to collect to collect the following tags from <ProductInformation>
<ProductInformation> has following child nodes and I need to collect them
LineNumber
SKUNumber
OrderedQuantity
ShippedQuantity
UOM
The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
My XML file is as follows
<?xml version="1.0" encoding="iso-8859-1" ?>
- <ShipmentHeader>
<AccountID />
- <OrderShipment>
<VendorNumber>1000</VendorNumber>
<OrderNumber>P00009238</OrderNumber>
<OrderType>Stock</OrderType>
<Company />
<Division />
<Department />
<Date>20061120</Date>
<CartonCount>2</CartonCount>
<ShipAllProducts>No</ShipAllProducts>
- <ShipmentDetail>
<TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
<Freight>000000010000</Freight>
<ShipmentDate>20061120</ShipmentDate>
<ShipmentMethod>UPS1PS</ShipmentMethod>
</ShipmentDetail>
- <ProductInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000001000000</OrderedQuantity>
<ShippedQuantity>00000001000000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <ProductInformation>
<LineNumber>000000002</LineNumber>
<SKUNumber>938EN</SKUNumber>
<AdvSKUNumber>001 7294</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000000450000</OrderedQuantity>
<ShippedQuantity>00000000450000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
<CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
- </OrderShipment>
</ShipmentHeader>
My Program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ts_shipment,
VendorNumber(10) TYPE n,
OrderNumber(20) TYPE n,
OrderType(8) TYPE c,
Date(8) TYPE c,
END OF ts_shipment.
TYPES: BEGIN OF ts_shipmentdetail,
TrackingNumber(30) TYPE n,
Freight(12) TYPE n,
Weight(14) TYPE n,
ShipmentDate(8) TYPE c,
ShipmentMethod(8) TYPE c,
END OF ts_shipmentdetail.
TYPES: BEGIN OF ts_productinformation,
LineNumber(9) TYPE n,
SKUNumber(20) TYPE c,
OrderedQuantity(14) TYPE n,
ShippedQuantity(14) TYPE n,
UOM(4) TYPE c,
END OF ts_productinformation.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_shipment TYPE STANDARD TABLE OF ts_shipment,
gs_shipment TYPE ts_shipment.
DATA: gt_shipmentdetail TYPE STANDARD TABLE OF ts_shipmentdetail,
gs_shipmentdetail TYPE ts_shipmentdetail.
DATA: gt_productinformation TYPE STANDARD TABLE OF ts_productinformation,
gs_productinformation TYPE ts_productinformation.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
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
not_supported_by_gui = 17
error_no_gui = 18
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.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPMENT".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPMENT'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPDET".
GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPDET'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPRODDET".
GET REFERENCE OF gt_productinformation INTO gs_result_xml-value.
gs_result_xml-name = 'IPRODDET'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION z_xml_to_abap3
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Writing the data from file for gt_shipment
*Collecting the Shipping Data from the XML file to internal table gt_shipment
*and writing the data to the screen
LOOP AT gt_shipment INTO gs_shipment.
WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
WRITE: / 'OrderType :', gs_shipment-OrderType.
WRITE: / 'Date :', gs_shipment-Date.
WRITE : /.
ENDLOOP. "gt_shipment.
LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
WRITE: / 'TrackingNumber:', gs_shipmentdetail-TrackingNumber.
WRITE: / 'Freight :', gs_shipmentdetail-Freight.
WRITE: / 'Weight :', gs_shipmentdetail-Weight.
WRITE: / 'ShipmentDate :', gs_shipmentdetail-ShipmentDate.
* WRITE: / 'ShipmentMethod :' gs_shipmentdetail-ShipmentMethod
WRITE : /.
ENDLOOP. "gt_shipmentdetail.
LOOP AT gt_productinformation INTO gs_productinformation.
WRITE: / 'LineNumber:', gs_productinformation-LineNumber.
WRITE: / 'SKUNumber :', gs_productinformation-SKUNumber.
WRITE: / 'OrderedQuantity :', gs_productinformation-OrderedQuantity.
WRITE: / 'ShippedQuantity :', gs_productinformation-ShippedQuantity.
WRITE: / 'UOM :', gs_productinformation-UOM.
WRITE : /.
ENDLOOP. "gt_productinformation.
XSLT Program
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPMENT>
<xsl:apply-templates select="//OrderShipment"/>
</ISHIPMENT>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="OrderShipment">
<item>
<VENDORNUMBER>
<xsl:value-of select="VendorNumber"/>
</VENDORNUMBER>
<ORDERNUMBER>
<xsl:value-of select="OrderNumber"/>
</ORDERNUMBER>
<ORDERTYPE>
<xsl:value-of select="OrderType"/>
</ORDERTYPE>
<DATE>
<xsl:value-of select="Date"/>
</DATE>
</item>
</xsl:template>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPDET>
<xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
</ISHIPDET>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="ShipmentDetail">
<item>
<TRACKINGNUMBER>
<xsl:value-of select="TrackingNumber"/>
</TRACKINGNUMBER>
<FREIGHT>
<xsl:value-of select="Freight"/>
</FREIGHT>
<SHIPMENTDATE>
<xsl:value-of select="ShipmentDate"/>
</SHIPMENTDATE>
<SHIPMENTMETHOD>
<xsl:value-of select="ShipmentMethod"/>
</SHIPMENTMETHOD>
</item>
</xsl:template>
</xsl:transform> .
Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
Any Help will be highly apppreciated. Thanks in advance
Regards,
Jessica Sam -
Upload vendor master data from legacy system to internal table tcode xk01
through batch input program how to upload vendor master data from legacy system to internal table and then to SAP R/3 database(transaction XK01) by using recording method.
By learning the basics of BDC recording and the use of GUI_UPLOAD
-
Retrieving data from Excel format to internal table(deep structure)
hi all,
can anybody help me how to Retrieving data from Excel format to internal table(deep structure)
and if u have any sample code for that please send it.
my internal table is like this
DATA: BEGIN OF ty_text,
vbeln TYPE vbeln,
posnr TYPE posnr,
seqno TYPE seqno,
textid TYPE tdid,
tdline TYPE tdline,
END OF ty_text.
DATA: BEGIN OF ty_item,
vbeln TYPE vbeln,
posnr TYPE posnr,
dispct1(16),
dispct2(16),
dispct3(16),
text LIKE table of ty_text,
END OF ty_item.hi,
check this code
TABLES:zmatnr.
TYPE-POOLS truxs.
DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA row LIKE alsmex_tabline-row.
data : gi_final like zmatnr occurs 0 with header line.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.
PERFORM search.
START-OF-SELECTION.
perform process.
form process.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pfname
i_begin_col = 1
i_begin_row = 2
i_end_col = 12
i_end_row = 65000
TABLES
intern = itab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
describe table itab lines itab_count.
row = 1.
loop at itab.
if itab-row <> row.
append gi_final.
clear gi_final.
endif.
case itab-col.
when '1'.
gi_final-MATNR = itab-value.
when '2'.
gi_final-Maktx = itab-value.
endcase.
row = itab-row.
endloop.
append gi_final.
clear gi_final.
endform.
FORM search .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = pfname.
ENDFORM.
regards
siva -
Read the last record of an internal table
Hello All,
I need to read the last entry of the internal table? Is it possible to achieve this without using loop - endloop?
In the following example, I need to get the Batch '110776' and store it in a variable.
ITAB:
MATNR|CHARG
010780|110770
010780|110772
010780|110773
010780|110774
010780|110775
010780|110776
Thanks.Use DESCRIBE to get the number of entires in variable last_entry
and then use read table ....index last_entry -
Populate data from itab to dynamic internal table
Hi All,
I have internal table it_tab with below data
"-----internal table it_tab data
1 0000123 GBP DA S 6265.45
2 0000123 GBP DA H 240.51
3 0000123 GBP DA S 35.82
4 0000123 GBP D1 H 281.85
5 0000123 GBP D1 S 23.41
6 0000123 GBP D1 S 34.23
7 0000123 GBP RV H 97.02
8 0000123 GBP RV S 52.90
9 0000123 GBP RV S 148.31
I have created dynamic internal table <t_dyn_table> using field-symbol based in dynamic fieldcatelog it_fldcat, using below code
Create dynamic internal table and assign to Field Symbol
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = it_dynamic_table
EXCEPTIONS
generate_subpool_dir_full = 1
others = 2.
IF sy-subrc eq 0.
ASSIGN it_dynamic_table->* TO <t_dyn_table>.
Create dynamic work area and assign to Field Symbol
CREATE DATA it_newline LIKE LINE OF <t_dyn_table>.
ASSIGN it_newline->* TO <wa_dyn>.
ENDIF.
Now I want to put the data from it_tab to <t_dyn_table> as shown below
Customer ___DAS ___D1S___RVS___DAH___D1H___RVH___DAT____D1T____RVT
0000123____6265.45__________________________________6265.45
0000123________________________240.51_______________240.51
0000123____35.82____________________________________35.82
Please help me out, Thanks in Advance
Thanks & Regards
Sekhar
Thanks in Advance
SekharHi Sekhar_tech,
Hope this helps. I made the code in notepad may have any syntax errors but the idea of the code is.
loop at it_tab into wa_tab.
UNASSIGN <wa_dyn>.
ASSIGN it_newline->* TO <wa_dyn>.
if <wa_dyn> is assigned.
UNASSIGN <lf_field_Value>.
ASSIGN COMPONENT 'CUSTOMER' OF STRUCTURE
<wa_dyn> TO <lf_field_value>.
IF <lf_field_Value> IS ASSIGNED.
<lf_field_value> = wa_tab-customer.
ENDIF.
UNASSIGN <lf_field_Value>.
ASSIGN COMPONENT 'DAS' OF STRUCTURE
<wa_dyn> TO <lf_field_value>.
IF <lf_field_Value> IS ASSIGNED.
<lf_field_value> = wa_tab-das.
ENDIF.
#same logic to other fields...
#The final step
APPEND <wa_dyn> TO <t_dyn_table>.
endif.
endloop.
Regards
Bruno Xavier. -
To populate data in standard order from internal table
Hi ppl,
I want to populate data from my internal table into stndard order in crm.i.e i also have to create a new order,and display those values in the general tab of crmd_order transaction.
For this purpose which transaction should be used?i have tried using crm_order_maintain,but wht are the mandatory fields for this transaction.
and if any other function module can be used for this purpose.
Pleaseee help....Hi Vaishali,
For existing order : You will have to pass the Header Guid of the line item which you are maintaining.
For new order : For creating a line item, you must create a header in CRM.
PS : Please see the where used list of the BAPI's you will come to know the usage.
<b>Reward points if it helps.</b> -
Hi all,
I am new to ABAP Development. I need to upload a .DAT file (the file doesn#t have any proper structure-- Please find the .DAT file in the attachment). After uploading the DATA (.DAT) fiel I need to split in into different columns. Refering the attached .DAT fiel the fields in bracets like:
[Arbeitstag], [Pecunia], [Mita], [Kunde], [Auftrag] and [Position] are different fields that need to be arranged in columns in an internal table. this .DAT fiel which I want to upload and then SPLIT it into various fields will will treated as MASTER DATA table for further programming. The program that I had written is as below. Also please refer the attached .DAT table.
Please if any one could help me. i searched a lot in different forums but couldn't find me a solution. Also note that the attached fiel is in text (.txt) format here but in real situation the same fiel is in DATA (.DAT) format.
*& Report ZDEMO_ZEITERFASSUNG9
REPORT ZDEMO_ZEITERFASSUNG9.
Types: Begin of ttab,
Rec(1000) type c,
End of ttab.
DATA: itab type table of ttab.
DATA: wa_tab type ttab.
DATA: file_str type string.
Parameters: p_file type localfile.
At selection-screen on value-request for p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
STATIC = 'X'
* MASK = ' '
CHANGING
file_name = p_file.
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
Start-of-Selection.
file_str = P_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\BUP_ZEIT.DAT' " This the file source address
FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = ';'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = itab
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.
LOOP at itab into wa_tab.
WRITE: / wa_tab.
ENDLOOP.
I will be grateful to all you experts for ur inputs
regards
Chandan SinghFor every Auftrag, there are multiple Position entries.
Rest of the blocks don't seems to have any relation.
So you can check this code to see how internal table lt_str is built whose first 3 fields have data contained in Auftrag, and next 3 fields have Position data. The structure is flat, assuming that every Position record is related to preceding Auftrag.
Try out this snippet.
DATA lt_data TYPE TABLE OF string.
DATA lv_data TYPE string.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = 'C:\temp\test.txt'
CHANGING
data_tab = lt_data
EXCEPTIONS
OTHERS = 19.
CHECK sy-subrc EQ 0.
TYPES:
BEGIN OF ty_str,
a1 TYPE string,
a2 TYPE string,
a3 TYPE string,
p1 TYPE string,
p2 TYPE string,
p3 TYPE string,
END OF ty_str.
DATA: lt_str TYPE TABLE OF ty_str,
ls_str TYPE ty_str,
lv_block TYPE string,
lv_flag TYPE boolean.
LOOP AT lt_data INTO lv_data.
CASE lv_data.
WHEN '[Version]' OR '[StdSatz]' OR '[Arbeitstag]' OR '[Pecunia]'
OR '[Mita]' OR '[Kunde]' OR '[Auftrag]' OR '[Position]'.
lv_block = lv_data.
lv_flag = abap_false.
WHEN OTHERS.
lv_flag = abap_true.
ENDCASE.
CHECK lv_flag EQ abap_true.
CASE lv_block.
WHEN '[Auftrag]'.
SPLIT lv_data AT ';' INTO ls_str-a1 ls_str-a2 ls_str-a3.
WHEN '[Position]'.
SPLIT lv_data AT ';' INTO ls_str-p1 ls_str-p2 ls_str-p3.
APPEND ls_str TO lt_str.
ENDCASE.
ENDLOOP. -
Space removed from character data type when move to internal table issue...
Hi Friends,
I converted material code and other details into internal table which have corresponding data types.But in internal table,I can see material code as left justified ,but after that space was removed.For example if material code is 'ABC' then rest of the space(material char(18)) are removed.But I need remaining spaces.I tried to concatenate material code with spaces (caoncatenate matnr ` ` int etc .. )at right side and moved to another internal table.Its working.But the problem is material codes have different values like one material 'ABC' and another like '123893-h' etc.So I need to calculate the space(out of char 18) dynamiclly and need to put space based on material code value.
<< Moderator message - Everyone's problem is important >>
.Thank you all..
Regards,
Kumaran..
Edited by: Rob Burbank on Oct 26, 2010 11:18 AMHi Ramkumaran,
You have not told the purpose of having these spaces.
is it for transfering to a file?
If that is the case, use a table with fixed lenght lines instead of many fields.
i.e. try something like this
DATA : i_tab type standard table of BUSDATA,
wa_tab type BUSDATA.
wa_tab+0(10) = material number.
wa_tab+10(10) = material code.
wa_tab+20(4) = company code...
append wa_tab to i_tab.
Thanks
Vimal -
Data upload from xls to internal table
Suppose I have data in the form of a matrix and I need to upload the data into the database after validation. The excel sheet is of the format:
Emp Empdept E1 E2 E3 E4 E5 E6 E7 E8 E9
E1 MEC 0 2 3 4 5 6 6 5 7
E2 ELE 4 0 5 5 6 2 2 1 3
E3 ELE 4 4 0 6 1 4 7 8 9
E4 ECE 2 2 4 0 6 7 5 9 4
E5 CHE 7 8 9 5 0 5 6 1 3
E6 ELE 8 9 10 12 11 0 5 6 4
E7 MEC 4 5 4 6 7 6 0 5 7
E8 MEC 9 4 7 5 2 2 8 0 1
E9 ELE 1 5 2 4 2 6 4 6 0
The first column is the employee number
The second column is the employee department and
The matrix indicates the time taken by emplyee1 to be trained to handle position of employee E2 is 2 months (map using row of E1 and column of E2).
Similarly E9 to E8 is 6 months.
I have to get the above data into an internal table of the format
Emp_from Emp_to Duration
E1 E1 0
E1 E2 2
E1 E3 3
E1 E4 4
E1 E5 5
E1 E6 6
E1 E7 6
E1 E8 5
E1 E9 7
E2 E1 4
E2 E2 0
E2 E3 5
can someone help me in building the logic for this
regards,
seenuHI refer this program
in this
excel to internal table and then application server
*& Report ZSD_EXCEL_INT_APP
REPORT ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
f1(20),
f2(40),
f3(20),
end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
wa_tab2 type it_tab1,
w_message(100) TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = 'X'
MASK = ' '
CHANGING
file_name = file_nm
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '10'
i_end_row = '35'
tables
intern = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at it_tab.
case it_tab-col.
when '002'.
wa_tab2-f1 = it_tab-value.
when '004'.
wa_tab2-f2 = it_tab-value.
when '008'.
wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
append wa_tab2 to it_tab2.
clear wa_tab2.
endat.
endloop.
data : p_file TYPE rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
MESSAGE e001(zsd_mes).
EXIT.
ELSE.
*---Data is downloaded to the application server file path
LOOP AT it_tab2 INTO wa_tab2.
TRANSFER wa_tab2 TO p_file.
ENDLOOP.
ENDIF.
*--Close the Application server file (Mandatory).
CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop. -
Data is not coming in internal table
Hello Abapers,
Data is not coming in my internal table.
Plz tell me where I m wrong
SELECTION-SCREEN BEGIN OF BLOCK blk.
PARAMETERS: compcode LIKE vbrk-bukrs OBLIGATORY.
PARAMETERS: billtype LIKE vbrk-fkart OBLIGATORY.
SELECT-OPTIONS: billdate FOR vbrk-fkdat OBLIGATORY.
PARAMETERS : acgrpc LIKE vbrk-ktgrd OBLIGATORY.
PARAMETERS: acgrpm LIKE vbrp-ktgrm OBLIGATORY.
PARAMETERS: taxcode LIKE konv-mwsk1 OBLIGATORY.
SELECT-OPTIONS: plant FOR vbrp-werks .
SELECT-OPTIONS: bussarea FOR vbrp-gsber .
SELECTION-SCREEN END OF BLOCK blk.
START-OF-SELECTION.
SELECT avbeln afkart aknumv afkdat abelnr aktgrd abukrs axblnr
amwsbk bgsber bwerks bktgrm
FROM ( vbrk AS a INNER JOIN vbrp AS b ON
avbeln EQ bvbeln )
INTO CORRESPONDING FIELDS OF TABLE vbrk_vbrp
WHERE ( a~fkart EQ billtype ) AND
( a~fkdat IN billdate ) AND
( a~ktgrd EQ acgrpc ) AND
( a~bukrs EQ compcode ) AND
( b~gsber EQ bussarea ) and
( b~werks EQ plant ) AND
( b~ktgrm EQ acgrpm ) .
RaviHi,
write ur query this way :
SELECT avbeln afkart aknumv afkdat abelnr aktgrd abukrs axblnr amwsbk bgsber bwerks bktgrm
FROM ( vbrk AS a INNER JOIN vbrp AS b ON
avbeln EQ bvbeln )
INTO CORRESPONDING FIELDS OF TABLE vbrk_vbrp
WHERE ( a~fkart EQ billtype ) AND
( a~fkdat IN billdate ) AND
( a~ktgrd EQ acgrpc ) AND
( a~bukrs EQ compcode ) AND
( b~gsber IN bussarea ) and
( b~werks IN plant ) AND
( b~ktgrm EQ acgrpm ) .
even plz check then internal table ' vbrk_vbrp ' if they have all the fields of select query and even the order is same as select , since you are using ' into corresponding fields of table ' clause in select statement.
hope this helps.
thanx,
dhanashri.
Edited by: Dhanashri Pawar on Aug 26, 2008 6:14 AM -
How to upload all excel files data from one folder into internal table.
Dear All,
I have one requirement, It is like I want to upload the frontend file data into my internal table, But here my scenario is;
If I have one folder ( Called : Temp) in my frontend system, in this folder ( Called : Temp) I have 100 excel files. In each excel file I have some 1000u2019s of entries. All these data of every file I want to take into my internal table.
If I have one file I can go for, CALL METHOD cl_gui_frontend_services=>file_open_dialog and then upload method to upload. But I want to take all these excel files from that folder at a time, is there any class or any thing is there..? plz help..
Thanks...
Edited by: satishsuri on Jan 11, 2011 9:33 AMHi satishsuri ,
You will have to use 3 methods together :
CALL METHOD cl_gui_frontend_services=>directory_browse "Browse the Directory
CALL METHOD cl_gui_frontend_services=>directory_list_files "Get all the files from the directory
CALL METHOD cl_gui_frontend_services=>gui_upload "Upload each file in a loop
Example:
TYPES: BEGIN OF ty_data,
line TYPE string,
END OF ty_data.
DATA: str_file TYPE string,
str_dir TYPE string,
it_file_table TYPE STANDARD TABLE OF file_info,
wa_file_table TYPE file_info,
v_count TYPE i,
it_data TYPE STANDARD TABLE OF ty_data,
wa_data TYPE ty_data.
CALL METHOD cl_gui_frontend_services=>directory_browse
CHANGING
selected_folder = str_dir.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = str_dir
CHANGING
file_table = it_file_table
count = v_count.
LOOP AT it_file_table INTO wa_file_table.
CONCATENATE str_dir wa_file_table-filename INTO str_file SEPARATED BY '\'.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = str_file
filetype = 'ASC'
CHANGING
data_tab = it_data.
LOOP AT it_data INTO wa_data.
WRITE : / wa_data-line.
ENDLOOP.
ULINE.
ENDLOOP.
Regards,
Jovito -
How do I extract the data of Variant configuration into internal tables
Hi Experts,
How can I extract the data of variant configuration into an internal tables while preparing the report.
Thanks,
bsv.Hi i´m not a "Expert.." but may I can help you:
CUCB_GET_VALUES_FROM_INSTANCE
Example:
Instance = MARA-CUOBF or
Instance = lips-cuobj
Result is the data of the Variant tables.
I need that for a simple report to evaluate customer & and his Variants......
Robert -
How to get data from maintaince view into internal table
Hi,
I want to get the all data from v_t179 (maintanence view) into intrenal table.
if i write select stmt , it is giving error.
I want all data into internal table.
regards,
AjayI think this is what you want:
TABLES: t179, t179t.
DATA: v_t179_int TYPE TABLE OF v_t179.
SELECT * FROM t179
JOIN t179t ON
t179~prodh = t179t~prodh
INTO CORRESPONDING FIELDS OF TABLE v_t179_int.
Rob -
DATA UPLOAD into 5 Different Internal Tables !!!
Hi ABAPers,
I have data in 5 different TABS of an Excel Sheet.
I have to UPLOAD this data in these different TABS to 5 different Internal tables.
Can any one give me a solution to this ???take data from all internal tabels into final internal table.....and proceed in below way......
fill ur inetnal table and call call the below form DOWNLOAD_TO_EXCEL, This Form is displaying an internal table it_outtab
Move data from it_outtab to it_excel
it_excel will contain all the charecter fields
DATA : BEGIN OF IT_EXCEL OCCURS 0,
FLD1(32),
FLD2(32),
FLD3(32),
FLD4(32),
FLD5(32),
FLD6(32),
FLD7(32),
FLD8(32),
FLD9(32),
FLD10(32),
FLD11(32),
FLD12(32),
FLD13(32),
FLD14(32),
FLD15(32),
FLD16(32),
FLD17(32),
FLD18(32),
FLD19(32),
FLD20(32),
FLD21(32),
END OF IT_EXCEL.
FORM DOWNLOAD_TO_EXCEL.
PERFORM GET_FILE_NAME .
CLEAR IT_EXCEL.
REFRESH IT_EXCEL.
IF NOT FNAME IS INITIAL .
PERFORM POPULATE_HEADER_DETAIL.
LOOP AT IT_OUTTAB.
IT_EXCEL-FLD1 = IT_OUTTAB-BANFN.
IT_EXCEL-FLD2 = IT_OUTTAB-BNFPO.
IT_EXCEL-FLD3 = IT_OUTTAB-EBELN.
IT_EXCEL-FLD4 = IT_OUTTAB-EBELP.
IT_EXCEL-FLD5 = IT_OUTTAB-STYLE.
IT_EXCEL-FLD6 = IT_OUTTAB-SKU.
IT_EXCEL-FLD7 = IT_OUTTAB-LP_COLOR.
IT_EXCEL-FLD8 = IT_OUTTAB-MAKTX.
IT_EXCEL-FLD9 = IT_OUTTAB-CURR_PRICE.
IF NOT IT_OUTTAB-VALID_FROM IS INITIAL.
CONCATENATE IT_OUTTAB-VALID_FROM+4(2) '/'
IT_OUTTAB-VALID_FROM+6(2) '/'
IT_OUTTAB-VALID_FROM(4) INTO IT_EXCEL-FLD10.
ENDIF.
IF NOT IT_OUTTAB-VALID_TO IS INITIAL.
CONCATENATE IT_OUTTAB-VALID_TO+4(2) '/'
IT_OUTTAB-VALID_TO+6(2) '/'
IT_OUTTAB-VALID_TO(4) INTO IT_EXCEL-FLD11.
ENDIF.
IT_EXCEL-FLD12 = IT_OUTTAB-FUT_PRICE.
IT_EXCEL-FLD13 = IT_OUTTAB-FAC_PRICE.
IF NOT IT_OUTTAB-FAC_VALID_FROM IS INITIAL.
CONCATENATE IT_OUTTAB-FAC_VALID_FROM+4(2) '/'
IT_OUTTAB-FAC_VALID_FROM+6(2) '/'
IT_OUTTAB-FAC_VALID_FROM(4) INTO IT_EXCEL-FLD14.
ENDIF.
IF NOT IT_OUTTAB-FAC_VALID_TO IS INITIAL.
CONCATENATE IT_OUTTAB-FAC_VALID_TO+4(2) '/'
IT_OUTTAB-FAC_VALID_TO+6(2) '/'
IT_OUTTAB-FAC_VALID_TO(4) INTO IT_EXCEL-FLD15.
ENDIF.
IT_EXCEL-FLD16 = IT_OUTTAB-JPN_PRICE.
IT_EXCEL-FLD17 = IT_OUTTAB-EAN11_1.
IT_EXCEL-FLD18 = IT_OUTTAB-EAN11_2.
IT_EXCEL-FLD19 = IT_OUTTAB-HANG_TAG_STAT.
IT_EXCEL-FLD20 = IT_OUTTAB-LABEL_STAT.
IT_EXCEL-FLD21 = IT_OUTTAB-CJI_STAT.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
ENDLOOP.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
CHECK_VERSION = ' '
DATA_NAME = FNAME
DATA_PATH_FLAG = ''
DATA_TYPE = 'DAT'
DATA_BIN_FILE_SIZE =
MACRO_NAME = ' '
MACRO_PATH_FLAG = 'E'
FORCE_START = ' '
WAIT = ''
IMPORTING
WINID =
TABLES
DATA_TAB = IT_EXCEL
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
WRONG_VERSION = 3
INTERNAL_ERROR = 4
INVALID_TYPE = 5
CANCELLED = 6
DOWNLOAD_ERROR = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF .
ENDFORM. " DOWNLOAD_TO_EXCEL
FORM GET_FILE_NAME.
DATA: TMP_FILENAME LIKE RLGRAP-FILENAME,
GLOBAL_FILEMASK_ALL(80),
GLOBAL_FILEMASK_MASK(20), GLOBAL_FILEMASK_TEXT(20),
GLOBAL_DOWNLOAD_PATH LIKE RLGRAP-FILENAME,
DEF_PATH LIKE RLGRAP-FILENAME,
FIELDLN TYPE I,
MODE TYPE C,
TMP_MASK LIKE GLOBAL_FILEMASK_ALL.
FIELD-SYMBOLS: .
IF GLOBAL_FILEMASK_MASK IS INITIAL.
TMP_MASK = ',.,..'.
ELSE.
TMP_MASK = ','.
WRITE GLOBAL_FILEMASK_TEXT TO TMP_MASK+1.
WRITE ',' TO TMP_MASK+21.
WRITE GLOBAL_FILEMASK_MASK TO TMP_MASK+22.
WRITE '.' TO TMP_MASK+42.
CONDENSE TMP_MASK NO-GAPS.
ENDIF.
IF NOT GLOBAL_FILEMASK_ALL IS INITIAL.
TMP_MASK = GLOBAL_FILEMASK_ALL.
ENDIF.
FIELDLN = STRLEN( DEF_PATH ) - 1.
ASSIGN DEF_PATH+FIELDLN(1) TO .
ENDIF.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = FNAME "rlgrap-filename
DEF_PATH = DEF_PATH
MASK = TMP_MASK
MODE = MODE
TITLE = ' '
IMPORTING
FILENAME = FNAME
RC =
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC = 0.
FNAME = TMP_FILENAME.
ELSE.
ENDIF.
ENDFORM. " GET_FILE_NAME
FORM POPULATE_HEADER_DETAIL.
IT_EXCEL-FLD8 = 'S U D H E E R'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = 'Price Validation Report'.
IT_EXCEL-FLD14 = 'Page'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = 'Vendor Number/Name'.
IT_EXCEL-FLD3 = 'Plan Month'.
IT_EXCEL-FLD4 = 'Effective In-store-Date'.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
IT_EXCEL-FLD1 = VENDOR_NAME.
IT_EXCEL-FLD3 = P_BEDNR.
IT_EXCEL-FLD4 = P_EFF_DT.
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
sudheer start
APPEND IT_EXCEL.
IT_EXCEL-FLD1 = 'PR'.
IT_EXCEL-FLD2 = 'Line'.
IT_EXCEL-FLD3 = 'PO'.
IT_EXCEL-FLD4 = 'PO Line'.
IT_EXCEL-FLD5 = 'Style'.
IT_EXCEL-FLD6 = 'SKU'.
IT_EXCEL-FLD7 = 'Long Color'.
IT_EXCEL-FLD8 = 'Material Description'.
IT_EXCEL-FLD9 = 'Current Price'.
IT_EXCEL-FLD10 = 'validity'.
IT_EXCEL-FLD11 = 'Period'.
IT_EXCEL-FLD12 = 'Future Price'.
IT_EXCEL-FLD13 = 'Factory Price'.
IT_EXCEL-FLD14 = 'Validity'.
IT_EXCEL-FLD15 = 'Period'.
IT_EXCEL-FLD16 = 'Japan Price'.
IT_EXCEL-FLD17 = 'First UPC'.
IT_EXCEL-FLD18 = 'Factory UPC'.
IT_EXCEL-FLD19 = 'Hang Tag Status'.
IT_EXCEL-FLD20 = 'Label Status'.
IT_EXCEL-FLD21 = 'CJI Label Status'.
*sudheer end
APPEND IT_EXCEL.
CLEAR IT_EXCEL.
ENDFORM. " POPULATE_HEADER_DETAIL
Check these links for sample code :
http://www.sapdevelopment.co.uk/ms/ms_excel.htm
please check this example:
FORM download.
DATA: lh_file1 TYPE rlgrap-filename,
lh_file2 TYPE rlgrap-filename,
lh_file3 TYPE rlgrap-filename,
lh_datda(1).
CLEAR: lh_file1, lh_file2, lh_file3.
Download neue Daten
CONCATENATE xh_pfad 'Datafile materialmaster new ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file1.
working area
DATA: index TYPE i,
lh_col TYPE i.
FIELD-SYMBOLS: .
SORT xt_bmm00 BY matnr.
SORT xt_bmmh1 BY matnr.
SORT xt_bmmh4 BY matnr.
SORT xt_bmmh7 BY matnr.
IF NOT xt_bmm00[] IS INITIAL.
MOVE 'X' TO lh_datda.
DO 4 TIMES.
CASE sy-index.
WHEN 1.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh7 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 2.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH4'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH4'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S004'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh4.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh4 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 3.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH1'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH1'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S003'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
Die folgende Abfrage ist notwendig, weil der Namensraum ZZ...
in der Struktur nicht erlaubt ist, aber im Excel-Sheet als
Überschrift gebraucht wird.
IF xt_ftab-fieldname = 'SPIRIDON'.
MOVE 'ZZSSN' TO xt_ftab-fieldname.
ENDIF.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmmh1.
index = sy-tabix + 1.
DO 72 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmmh1 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 4.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMM00'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMM00'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S002'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_bmm00.
index = sy-tabix + 1.
DO 21 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_bmm00 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
ENDCASE.
ENDDO.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file1.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
Download geänderter Materialstammdaten
CONCATENATE xh_pfad 'Datafile materialmaster change ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file2.
IF NOT xt_emmh1[] IS INITIAL.
MOVE 'X' TO lh_datda.
DO 2 TIMES.
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
CASE sy-index.
WHEN 1.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = sy-index .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_emmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_emmh7 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
WHEN 2.
GET PROPERTY OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Add' = lh_newsheet .
SET PROPERTY OF lh_newsheet 'Name' = 'BMMH1'.
CALL METHOD OF lh_excel 'WorkSheets' = lh_activesheet
EXPORTING #1 = 'BMMH1'.
CALL METHOD OF lh_activesheet 'Activate' .
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S003'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
Die folgende Abfrage ist notwendig, weil der Namensraum ZZ...
in der Struktur nicht erlaubt ist, aber im Excel-Sheet als
Überschrift gebraucht wird.
IF xt_ftab-fieldname = 'SPIRIDON'.
MOVE 'ZZSSN' TO xt_ftab-fieldname.
ENDIF.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_emmh1.
index = sy-tabix + 1.
DO 72 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_emmh1 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
ENDCASE.
ENDDO.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file2.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
Download geänderter Texte
CONCATENATE xh_pfad 'Datafile materialmaster change PO ' sy-datum(4)
sy-datum4(2) sy-datum6(2) sy-uzeit '.xls' INTO lh_file3.
IF NOT xt_tmmh7[] IS INITIAL.
CLEAR: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
MOVE 'X' TO lh_datda.
CREATE OBJECT lh_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF lh_excel 'Visible' = 1 .
GET PROPERTY OF lh_excel 'Workbooks' = lh_workbooks .
GET PROPERTY OF lh_workbooks 'Application' = lh_application .
SET PROPERTY OF lh_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF lh_workbooks 'Add' = lh_workbook .
CALL METHOD OF lh_workbook 'Sheets' = lh_sheets .
CALL METHOD OF lh_sheets 'Item' = lh_sheet
EXPORTING #1 = 1 .
SET PROPERTY OF lh_sheet 'NAME' = 'BMMH7'.
Überschrift erstellen
CLEAR xt_ftab.
REFRESH xt_ftab.
CALL FUNCTION 'GET_FIELDTAB'
EXPORTING
langu = sy-langu
tabname = '/SIE/TS_MM01S005'
withtext = ' '
only = 'T'
TABLES
fieldtab = xt_ftab
EXCEPTIONS
OTHERS = 1.
CLEAR lh_col.
LOOP AT xt_ftab.
ADD 1 TO lh_col.
PERFORM fill_cell
USING 1 lh_col xt_ftab-fieldname lh_excel lh_cells.
ENDLOOP.
LOOP AT xt_tmmh7.
index = sy-tabix + 1.
DO 4 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE xt_tmmh7 TO lh_excel lh_cells.
ENDIF.
ENDDO.
ENDLOOP.
CALL METHOD OF lh_workbook 'SAVEAS'
EXPORTING #1 = lh_file3.
CALL METHOD OF lh_excel 'QUIT'.
FREE OBJECT: lh_cells, lh_sheet, lh_sheets, lh_application,
lh_workbook, lh_workbooks, lh_excel,
lh_chart, lh_activesheet.
ENDIF.
IF lh_datda NE 'X'.
MESSAGE i016.
ENDIF.
ENDFORM. " download
FORM fill_cell USING p_i
value
p_customer_cell1
h_excel
h_cells.
CALL METHOD OF h_excel 'Cells' = h_cells EXPORTING #1 = p_i #2 = value.
SET PROPERTY OF lh_cells 'Numberformat' = '@'.
SET PROPERTY OF h_cells 'Value' = p_customer_cell1.
ENDFORM. " fill_cell
Maybe you are looking for
-
Reports not retaining carriage returns from htmldb_item.textarea
Im created a tabular form for multi row updates using htmldb_item.textarea for one of the fields. When I update the tabular form it keeps any carriage returns in this field, which is good. I then created a PL/SQL function body returning a SQL Query
-
How do i set-up ipad nano for other user?
Hi, I want to buy my boyfriend an ipod nano for his birthday and set it up for him with all my music. I have a mac and he has a pc. How do i ensure that when i plug the nano for the first time it doesn't wipe all my songs? also can i set it up for hi
-
Safari crashing even after reinstalling
heres the error report.... Process: Safari [647] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 5.1.7 (7534.57.2) Build Info: WebBrowser-7534057002000000~1 Code Type:
-
Problem in generating User Login Report on System Usage
We want a daily shift-wise(3 shifts of 8 hours each) report with following information 1. User-ID 2. Login Time-Stamp 3. Transaction Code 4. Transaction Code Start Time-Stamp 5. Transaction Code End Time-Stamp 6. Logout Time-Stamp At present we
-
Relation between GR and Theoritical qty
Hi, I have an issue with a report program which fetches the PO and material data from ME23n.The program should display PO, material head, material quantity, GR qty, vendor, theoretical qty, Actual qty. Here for one of the POs, the GR qty is 1CU but t