POPUP Internal Table.
Good Morning,
I've build a report with <i>REUSE_ALV_GRID_DISPLAY</i>.
After displaying the result the user can execute another process using a button i've created in the STATUS_GUI of the ALV_GRID.
This process does several things, and one of them should be a popup of data i have in one of my internal tables.
I've searched for some functions that could popup an internal table to the screen (POPUP_WITH_TABLE_DISPLAY_OK, POPUP_WITH_TABLE_DISPLAY, POPUP_WITH_TABLE_DISPLAY_OK, POPUP_SHOW_INTTAB) but the display isn't what i wanted... I want to display a popup like a ALV_GRID or ALV_LIST.
Is there any function that does that? If not, how can i do it?
Best Regards,
Pedro Gaspar
hi ,
use <b>REUSE_ALV_POPUP_TO_SELECT</b>
Check out this code ..
REPORT z_alv_grid_and_popup.
* This program is an example with a Grid list and a Popup list *
* The Sales Orders are displayed in the first list *
* When a line is selected, the items of the order are displayed in *
* a popup list *
* Author : Michel PIOUD *
* Email : [email protected] HomePage : http://www.geocities.com/mpioud *
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TABLES : vbak. " Sales Document: Header Data
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
* Data displayed in the first list
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
END OF gt_vbak,
* Data displayed in the popup list
BEGIN OF gt_vbap OCCURS 0,
posnr LIKE vbap-posnr, " Sales document item
matnr LIKE vbap-matnr, " Material number
arktx LIKE vbap-arktx, " Short text for sales order item
kwmeng LIKE vbap-kwmeng, " Order quantity
netwr LIKE vbap-netwr, " Net value of the order item
END OF gt_vbap.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data_vbak.
PERFORM f_display_data_vbak.
* Form f_read_data_vbak
FORM f_read_data_vbak.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA_VBAK
* Form f_display_data_vbak
FORM f_display_data_vbak.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'VKORG' 'VBAK'.
m_fieldcat 'KUNNR' 'VBAK'.
m_fieldcat 'VBELN' 'VBAK'.
m_fieldcat 'NETWR' 'VBAK'.
* Display the first list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA_VBAK
* FORM USER_COMMAND *
FORM user_command USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE gt_vbak INDEX us_selfield-tabindex.
CHECK sy-subrc EQ 0.
PERFORM f_read_data_vbap. " Read data from VBAP
PERFORM f_display_data_vbap.
ENDCASE.
ENDFORM. " USER_COMMAND
* Form f_read_data_vbap
FORM f_read_data_vbap.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbap
FROM vbap
WHERE vbeln = gt_vbak-vbeln.
ENDFORM. " F_READ_DATA_VBAP
* Form f_display_data_vbap
FORM f_display_data_vbap.
DATA:
ls_private TYPE slis_data_caller_exit,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'POSNR' 'VBAP'.
m_fieldcat 'MATNR' 'VBAP'.
m_fieldcat 'ARKTX' 'VBAP'.
m_fieldcat 'KWMENG' 'VBAP'.
m_fieldcat 'NETWR' 'VBAP'.
ls_private-columnopt = 'X'. " Optimize width
* Display items in a POPUP
CALL FUNCTION <b>'REUSE_ALV_POPUP_TO_SELECT'</b>
EXPORTING
i_selection = ' '
i_tabname = 'GT_VBAP'
it_fieldcat = lt_fieldcat
is_private = ls_private
TABLES
t_outtab = gt_vbap.
ENDFORM. " F_DISPLAY_DATA_VBAP
**************** END OF PROGRAM Z_ALV_GRID_AND_POPUP ******************
Regards,
Santosh
Similar Messages
-
Internal table values in a popup window
Hi All,
i'm new to WD..
i have a dynamic internal table(only one field) in my WDA. i want to show all the values as POPUP on the screen after user press the button. please let me know how can i procced for this? also after selecting the rows from Popup table, i want the fields selected to be placed into another internal table.
please let me know how can i do this..
Thanks in advance
ShekharHi Shekhar,
Have you actually populated your internal table I_TAB with any data? Am asking so coz I dont find anything related to that in here. You have just obtained your context node's reference & have written a bind_table to that. Have you actually filled this internal table by using WDDOINIT method or a supply function?
Regards,
Uday
Am sorry I had earlier given you a link to invalid tutorial. Plz find the correct link for the task I had explained earlier in [here|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm].
Below is the code that I have in my push button.I read the KUNNR value entered by the user & fetch the corresponding sales order information & bind it to my context node. I then map this context node to the view embedded within my popup view.
METHOD onactiondisplay_popup .
DATA: lv_node TYPE REF TO if_wd_context_node,
lv_kunnr TYPE ig_componentcontroller=>element_kna1-kunnr,
lt_vbak TYPE ig_componentcontroller=>elements_vbak.
* get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
lv_node = wd_context->get_child_node( name = 'KNA1' ).
CALL METHOD lv_node->get_attribute
EXPORTING
name = 'KUNNR'
IMPORTING
value = lv_kunnr.
SELECT * FROM vbak INTO TABLE lt_vbak WHERE kunnr = lv_kunnr.
IF sy-subrc NE 0.
* report message
CALL METHOD lo_message_manager->report_error_message
EXPORTING
message_text = 'No sales orders exist for this customer!'.
ELSE.
lv_node = wd_context->get_child_node( name = 'VBAK' ).
lv_node->bind_table( new_items = lt_vbak ).
DATA lo_window_manager TYPE REF TO if_wd_window_manager.
DATA lo_api_component TYPE REF TO if_wd_component.
DATA lo_window TYPE REF TO if_wd_window.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'POPUP_WINDOW'
title = 'Working with modal windows in webdynpro!'
close_in_any_case = abap_true ).
lv_node = wd_context->get_child_node( name = 'WINDOW_REFERENCE' ).
lo_window->open( ).
ENDIF.
ENDMETHOD. "onactiondisplay_popup -
Popup dialog with 3 buttons to show internal table
Hi,
Is there any popup dialog that can show internal table and with 3 buttons?
Just like the combination of POPUP_WITH_3_BUTTONS_TO_CHOOSE and POPUP_WITH_TABLE.
Thanks in advance.hi,
Use FM 'POPUP_TO_CONFIRM'.
Check the below example code
data parameters like spar occurs 0 with header line.
data Name(75) type c.
name = ' '.
Data : v_ecc6_text type string,
v_ecc6_title type string.
DATA: L_SVAR(1).
concatenate
'1'
'2'
'3'
into Name separated by space.
move Name to parameters-value.
move 'NAME' to parameters-param.
append parameters.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Hai'
DIAGNOSE_OBJECT = 'ZDIALOG_TEXT'
TEXT_QUESTION = 'Hello'
DEFAULT_BUTTON = '1'
IMPORTING
ANSWER = L_SVAR
TABLES
PARAMETER = parameters
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
Edited by: Raj on Jul 1, 2008 1:03 AM -
How to return an internal table with methods ?
Hi,
I am an Java programmer and very new to ABAP.
How do I return a internal table with a method? I have the table GP1_PRODUCTS and want to return a copy of this table as an internal table called PRODUCTS.
Here is my code that does not work:
class PRODUCTS definition
public
final
create public .
public section.
*"* public components of class PRODUCTS
*"* do not include other source files here!!!
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type GP1_PRODUCTS .
protected section.
*"* protected components of class PRODUCTS
*"* do not include other source files here!!!
private section.
*"* private components of class PRODUCTS
*"* do not include other source files here!!!
ENDCLASS.
CLASS PRODUCTS IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method PRODUCTS->GET_PRODUCT_LIST
* +-------------------------------------------------------------------------------------------------+
* | [<-()] PRODUCTS TYPE GP1_PRODUCTS
* +--------------------------------------------------------------------------------------</SIGNATURE>
method GET_PRODUCT_LIST.
DATA: it_products TYPE STANDARD TABLE OF GP1_PRODUCTS.
select * from GP1_PRODUCTS into table it_products.
PRODUCTS = it_products.
endmethod.
ENDCLASS.You have to create a table type for your table GP1_PRODUCTS.
If you use global class (created in SE24), than:
Create a Table Type in SE11
Go to SE11, Enter a name like ZPRODUCTS in the Data Type
There will be popup when you press the Create button to decide a type. Select the Table Type
Enter GP1_PRODUCTS in the Line Type.
* method declaration
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type ZPRODUCTS.
If you use local class:
TYPES: ty_products type standard table of GP1_PRODUCTS..
* method declaration
methods GET_PRODUCT_LIST
returning
value(PRODUCTS) type ty_products
Regards,
Naimesh Patel -
Append new column to internal table
Hi all,
i have an internal table that was generated based on an ddic structure - now i want to add a column to that table. how can i do that ?
thank you!
clemensHi to all, thank you for your help! here is the code that i have:
REPORT *************_4 .
TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
TYPE-POOLS: slis.
TABLES: dd03l, dd04t.
TYPES:
BEGIN OF ty_table_struct,
fieldname TYPE dd03l-fieldname, " Tabellenname
ddtext TYPE dd04t-ddtext, " Kurztext
checkbox,
END OF ty_table_struct.
DATA:t_fieldcat TYPE slis_t_fieldcat_alv,
w_fieldcat TYPE slis_fieldcat_main.
DATA:
gt_table_struct TYPE TABLE OF ty_table_struct.
DATA: v_repid TYPE sy-repid.
DATA:
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat,
l_tab_fields TYPE STANDARD TABLE OF ty_table_struct,
w_tab_fields LIKE LINE OF l_tab_fields.
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(28) v_1 FOR FIELD p_table.
PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY VALUE CHECK.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Tabelle für Dublettenprüfung'.
v_repid = sy-repid.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.
*& Form get_structure
FORM get_structure.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
READ TABLE l_tab_fields INTO w_tab_fields
WITH KEY fieldname = xdetails-name.
IF sy-subrc = 0.
CLEAR xfc.
xfc-fieldname = xdetails-name.
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDIF.
ENDLOOP.
ENDFORM. "get_structure
*& Form create_dynamic_itab
* text
FORM create_dynamic_itab.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab
*& Form get_data
* text
FORM get_data.
* Select Data from table.
SELECT (l_tab_fields) INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FROM (p_table).
ENDFORM. "get_data
*& Form write_out
* text
FORM write_out.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_structure_name = p_table
CHANGING
ct_fieldcat = t_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
* Show only fields that are needed
LOOP AT t_fieldcat INTO w_fieldcat.
READ TABLE l_tab_fields INTO w_tab_fields
WITH KEY fieldname = w_fieldcat-fieldname.
IF sy-subrc <> 0.
DELETE t_fieldcat.
ENDIF.
ENDLOOP.
w_fieldcat-tabname = '<dyn_table>'.
w_fieldcat-fieldname = 'NETPR'.
w_fieldcat-seltext_m = 'Net Price'.
w_fieldcat-outputlen = 15.
w_fieldcat-col_pos = 10.
* w_fieldcat-do_sum = 'X'. "Display column total
w_fieldcat-datatype = 'CURR'.
append w_fieldcat to t_fieldcat.
* Write out data from table.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = t_fieldcat
I_BYPASSING_BUFFER = 'X'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 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.
ENDFORM. "write_out
*& Form f_read_data
* text
FORM f_read_data.
SELECT * FROM ( dd03l
INNER JOIN dd04t
ON dd03l~rollname = dd04t~rollname
AND dd04t~ddlanguage = syst-langu
AND dd04t~as4local = 'A' ) INTO CORRESPONDING FIELDS OF
TABLE
gt_table_struct WHERE dd03l~tabname = p_table .
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-rollname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
DATA:
l_exit,
ls_private TYPE slis_data_caller_exit,
ls_field TYPE ty_table_struct,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'FIELDNAME' 'ty_table_struct' 'FIELDNAME'.
m_fieldcat 'DDTEXT' 'ty_table_struct' 'DDTEXT'.
* Optimize column width
ls_private-columnopt = 'X'.
* Display data in a popup
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_selection = 'X'
i_zebra = 'X'
it_fieldcat = lt_fieldcat
i_tabname = 'gt_table_struct'
i_checkbox_fieldname = 'CHECKBOX'
is_private = ls_private
IMPORTING
e_exit = l_exit
TABLES
t_outtab = gt_table_struct.
CHECK l_exit = space.
* write selected columns to the internal table for inclusion
* into fieldcat
LOOP AT gt_table_struct INTO ls_field WHERE checkbox = 'X'.
APPEND ls_field-fieldname TO l_tab_fields.
ENDLOOP.
ENDFORM.
What
i want it to do is, have the alvgrid displaying the fields from t_fieldcat, plus some fields ( that should be appended to the internal table before, i think ? ). What went wrong ?
Clemens -
Want to have F4 help from an internal table in Module Pool.
Hi,
I have a input/output field in a Module pool program. I want to attach an F4 help on this from an internal table.
Please suggest me some techniques.
Thanks in advance..Hi all,
This is the piece of code I have written...But I am getting the message "No Values Found"-
DECLARATION
TYPES:
BEGIN OF ty_shipto,
ship_to TYPE kunnr,
END OF ty_shipto.
DATA:
tb_shipto TYPE TABLE OF ty_shipto,
wa_shipto TYPE ty_shipto.
REFRESH:
tb_shipto.
CLEAR:
wa_shipto.
TABLE TB_SHIPTO IS FILLED
SELECT spart
FROM mara
INTO CORRESPONDING FIELDS OF TABLE mara_it
FOR ALL ENTRIES IN vlcvehicle_it
WHERE matnr = vlcvehicle_it-matnr.
LOOP AT vlcvehicle_it INTO vlcvehicle_ls.
MOVE-CORRESPONDING vlcvehicle_ls TO wa_vehinfo.
APPEND wa_vehinfo TO tb_vehinfo.
ENDLOOP.
LOOP AT mara_it INTO mara_ls.
MOVE-CORRESPONDING mara_ls TO wa_vehinfo.
APPEND wa_vehinfo TO tb_vehinfo.
ENDLOOP.
LOOP AT vlcvehicle_it INTO vlcvehicle_ls.
MOVE vlcvehicle_ls-vhcle TO va_vhcle.
CALL FUNCTION 'ZCN_SD_GET_VLC_BRAND'
EXPORTING
in_vhcle = va_vhcle
IMPORTING
out_distr_channel = va_vtweg.
MOVE va_vtweg TO wa_vtweg.
MOVE-CORRESPONDING wa_vtweg TO wa_vehinfo.
APPEND wa_vehinfo TO tb_vehinfo.
ENDLOOP.
CLEAR:
va_vtweg.
IF tb_vehinfo[] IS NOT INITIAL.
LOOP AT tb_vehinfo INTO wa_vehinfo.
MOVE wa_vehinfo-kunnr TO va_kunnr.
IF va_kunnr IS NOT INITIAL.
MOVE va_kunnr TO va_kunnr_final.
ENDIF.
MOVE wa_vehinfo-zvkorg TO va_vkorg.
IF va_vkorg IS NOT INITIAL.
MOVE va_vkorg TO va_vkorg_final.
ENDIF.
MOVE wa_vehinfo-spart TO va_spart.
IF va_spart IS NOT INITIAL.
MOVE va_spart TO va_spart_final.
ENDIF.
MOVE wa_vehinfo-vtweg TO va_vtweg.
IF va_vtweg IS NOT INITIAL.
MOVE va_vtweg TO va_vtweg_final.
ENDIF.
ENDLOOP.
ENDIF.
SELECT kunn2
FROM knvp
INTO TABLE tb_shipto
WHERE kunnr = va_kunnr_final AND
vkorg = va_vkorg_final AND
spart = va_spart_final AND
vtweg = va_vtweg_final AND
parvw = 'WE'.
POV- TXT_SHIPTO_NVAL_NAR IS THE FIELD NAME IN DYNPRO
PROCESS ON VALUE-REQUEST.
FIELD:
txt_shipto_nval_nar MODULE f4_help_shipto_nar.
MODULE f4_help_shipto_nar INPUT.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'SHIP_TO'
dynpprog = sy-repid
callback_program = sy-repid
dynpnr = sy-dynnr
dynprofield = 'TXT_SHIPTO_NVAL_NAR'
TABLES
value_tab = tb_shipto
return_tab = return_tab.
ENDMODULE. " M_F4_HELP_NVAL_SHIPTO INPUT
The code is runnig error free but I am unable to see any popup.
Message displayed: "No Values Found". But, I have checked in debugging that the table TB_SHIPTO contains some values when the FM is called.
Please point out the mistake.
Thanks in advance. -
Final internal table for me2j ?
Dear ABAPers,
I added extra field in MEREP_OUTTAB_ACCOUNTING structure.(Append-wrbtr)
now i need final internal table which is used to populate the me2j report?
so tell me the final internal table of me2j .
please help me!
Regards,
Praphull
Moderator Message: Duplicate Post.
Edited by: kishan P on Dec 26, 2011 3:28 PMDear Madhu,
thanks for guidence!
its showing popup tht this BADI ( ME_CHANGE_OUTTAB_CUS ) is only use for "SAP Internal use".
Regards,
Praphull -
Hi ,
I have created a view with a table inside. This table is bound to a node that contains data from a service
call.
The view is embeded in the window and the data in the table can be displayed on the screen. I would like
to print this table. How do I code this? Please give me suggestions.
ps. I don't want to display in ALV format.
Thanks,
AS.Hi Thomas,
I have created a view and a popup window. In this view context, I created a node that is bound to SFPPRIP structure.
I have user to enter output device (DEST) .
I don't know how to declear it_message and print_options to make the method PRINT to work.
Could you look at the code below and give me some suggestions on the input for the print method?
method GET_PRINT_PARAM .
* get print input
data: context_node type ref to if_wd_context_node,
elem_print type ref to if_wd_context_element,
stru_print type if_componentcontroller=>element_printing,
item_dest like stru_print-dest.
context_node = wd_context->get_child_node( name = 'PRINTINT' ).
elem_print = context_node->get_element( ).
elem_print->get_attribute(
exporting
name = 'DEST'
importing
value = item_dest ).
* fill the internal table
data: elem_sflightinfo type ref to if_wd_context_element,
stru_sflightinfo type table of if_componentcontroller=>element_sflightinfo initial size 0,
w_itab like line of stru_sflightinfo.
context_node = wd_context->get_child_node( name = 'SFLIGHTINFO').
select * from sflight
into corresponding fields of table stru_sflightinfo.
* BIND table to context node flighttab
call method context_node->bind_table
exporting
new_items = stru_sflightinfo.
* for print method
data: it_out type ref to data,
it_message type ref to CL_BSP_MESSAGES. "I know it is wrong, but what should I use?
get reference of stru_sflightinfo into it_out.
wd_this->print(
* col_def = " tableviewcontroltab
itab = it_out " ref to data
* iterator = " ref to if_htmlb_tableview_iterator
messages = it_message " ref to cl_bsp_messages(wrong. but what to pass?)
print_options = item_dest " sfpprip (I know it is wrong, but don't know what to pass?)
endmethod.
PRINT method
method PRINT .
FIELD-SYMBOLS: <tab> TYPE table.
ASSIGN itab->* TO <tab>.
****This sample uses the new ALV Object Model - Only available in WebAS 640+
****It will have to be changed (perhaps to use field catalogs and REUSE_ALV)
****in WebAS 620
DATA: table TYPE REF TO cl_salv_table.
DATA: print_parameters TYPE pri_params,
valid_flag(1) TYPE c.
****Convert the Input Print Parameters (Designed for Adobe Forms)
****Into the ABAP List format
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
authority = print_options-authority
copies = print_options-copies
cover_page = print_options-cover
data_set = print_options-dataset
department = print_options-division
destination = print_options-dest
expiration = print_options-lifetime
immediately = print_options-reqimm
layout = 'X_65_255'
list_name = print_options-suffix2
list_text = print_options-covtitle
new_list_id = print_options-reqnew
no_dialog = abap_true
receiver = print_options-receiver
release = print_options-reqdel
IMPORTING
out_parameters = print_parameters
valid = valid_flag
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF sy-subrc = 0 OR valid_flag NE abap_true.
messages->add_message2( condition = 'print'
message = 'Invalid Print Parameters'(e01) ).
RETURN.
ENDIF.
****Start List Processing with our Print Parameters
NEW-PAGE PRINT ON PARAMETERS print_parameters
NO DIALOG.
****Create the ALV Object Model
DATA: salv_msg TYPE REF TO cx_salv_msg.
DATA: error_string TYPE string.
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = abap_true
IMPORTING
r_salv_table = table
CHANGING
t_table = <tab> ).
CATCH cx_salv_msg INTO salv_msg.
messages->add_message_from_exception( condition = 'print'
exception = salv_msg ).
EXIT.
ENDTRY.
****Process the Column Definitions
DATA: columns TYPE REF TO cl_salv_columns_table.
****Get a reference to the columns object and set the optimize width.
columns = table->get_columns( ).
columns->set_optimize( abap_false ).
DATA: l_col_def TYPE tableviewcontroltab.
DATA: iterator_error TYPE REF TO cx_sy_dyn_call_illegal_method.
****We have an iterator Class - Process it and get a columun defintion table
IF col_def IS INITIAL AND
iterator IS NOT INITIAL.
DATA: p_overwrites TYPE tableviewoverwritetab.
TRY.
iterator->get_column_definitions(
EXPORTING
p_tableview_id = 'itab'
CHANGING
p_column_definitions = l_col_def
p_overwrites = p_overwrites ).
CATCH cx_sy_dyn_call_illegal_method INTO iterator_error.
messages->add_message_from_exception( condition = 'print'
exception = iterator_error ).
EXIT.
ENDTRY.
*****User supplied a column definition table directly - us it
ELSEIF col_def IS NOT INITIAL.
l_col_def = col_def.
ENDIF.
****Adjust our column definition (otherwise know as Field Catalog) by the
****Iterator or Column Dfinition table.
IF l_col_def IS NOT INITIAL.
DATA: scrtext_l TYPE scrtext_l,
scrtext_m TYPE scrtext_m,
scrtext_s TYPE scrtext_s,
tooltip TYPE lvc_tip.
DATA: col TYPE salv_t_column_ref.
FIELD-SYMBOLS: <wa_col> LIKE LINE OF col,
<wa_col_def> LIKE LINE OF l_col_def.
****Get a listing of all columns
col = columns->get( ).
****Loop through all the columsn
LOOP AT col ASSIGNING <wa_col>.
****Read to see if the current columns is in our Iterator
READ TABLE l_col_def ASSIGNING <wa_col_def>
WITH KEY columnname = <wa_col>-columnname.
IF sy-subrc = 0.
****Field is in the iterator - set it visible.
<wa_col>-r_column->set_visible( abap_true ).
****Is there an override title in the Iterator - if yes
****use it for all the column headers of the output
IF <wa_col_def>-title IS NOT INITIAL.
scrtext_l = <wa_col_def>-title.
scrtext_m = <wa_col_def>-title.
scrtext_s = <wa_col_def>-title.
<wa_col>-r_column->set_long_text( scrtext_l ).
<wa_col>-r_column->set_medium_text( scrtext_m ).
<wa_col>-r_column->set_short_text( scrtext_s ).
ENDIF.
****Is there an override tooltip in the Interator - if yes
****ues it for the tooltip of the output (actually meaningless
****for only printing - but hey you never know what you might
****use this for in the future :)
IF <wa_col_def>-tooltipheader IS NOT INITIAL.
tooltip = <wa_col_def>-tooltipheader.
<wa_col>-r_column->set_tooltip( tooltip ).
ENDIF.
ELSE.
****Field is not in the Iterator - Hide it in the output
<wa_col>-r_column->set_visible( abap_false ).
ENDIF.
ENDLOOP.
ENDIF.
****Set the ALV to display (forces printing in the Dark = background or BSP)
table->display( ).
NEW-PAGE PRINT OFF.
messages->add_message2( condition = 'print'
message = 'Print Output is complete'(i01)
messagetype = 'I' ).
endmethod.
Your help is greatly appreciated.
AS.
Edited by: Anna Smith on Dec 18, 2008 4:25 PM -
Sy-tabix for internal table in smartform
Hi friends,
How to capture the sy-tabix value for the entries in an internal table which has been looped into the loop of table node of a smartform?? I need to print something immedaitely after the end of the table
For every record the value of sy-tabix is showing 1 !!
Advance Thanks
AadarshHi Aadarsh,
Give ur sy-tabix at the end of the loop.
loop at itab.
//table node populations.
endloop.
give a seperate loop for this.
loop at itab.
sy-tabix.
endloop
get the total no and print it after the table.
If u r using do loop then give sy-index.
Hope tihs helps u,
Regards,
Nagarajan.
Message was edited by: Nagarajan Kumarappan -
Regarding Exporting and Importing internal table
Hello Experts,
I have two programs:
1) Main program: It create batch jobs through open_job,submit and close job.Giving sub program as SUBMIT.
I am using Export IT to memory id 'MID' to export internal table data to sap memory in the subprogram.
The data will be processed in the subprogram and exporting data to sap memory.I need this data in the main program(And using import to get the data,but it is not working).
Importing IT1 from memory id 'MID' to import the table data in the main program after completing the job(SUBMIT SUBPROGRAM AND RETURN).
Importing is not getting data to internal table.
Can you please suggest something to solve this issue.
Thank you.
Regards,
Anand.Hi,
This is the code i am using.
DO g_f_packets TIMES.
* Start Immediately
IF NOT p_imm IS INITIAL .
g_flg_start = 'X'.
ENDIF.
g_f_jobname = 'KZDO_INHERIT'.
g_f_jobno = g_f_jobno + '001'.
CONCATENATE g_f_jobname g_f_strtdate g_f_jobno INTO g_f_jobname
SEPARATED BY '_'.
CONDENSE g_f_jobname NO-GAPS.
p_psize1 = p_psize1 + p_psize.
p_psize2 = p_psize1 - p_psize + 1.
IF p_psize2 IS INITIAL.
p_psize2 = 1.
ENDIF.
g_f_spname = 'MID'.
g_f_spid = g_f_spid + '001'.
CONDENSE g_f_spid NO-GAPS.
CONCATENATE g_f_spname g_f_spid INTO g_f_spname.
CONDENSE g_f_spname NO-GAPS.
* ... (1) Job creating...
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = g_f_jobname
IMPORTING
jobcount = g_f_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e469(9j) WITH g_f_jobname.
ENDIF.
* (2)Report start under job name
SUBMIT (g_c_prog_kzdo)
WITH p_lgreg EQ p_lgreg
WITH s_grvsy IN s_grvsy
WITH s_prvsy IN s_prvsy
WITH s_prdat IN s_prdat
WITH s_datab IN s_datab
WITH p1 EQ p1
WITH p3 EQ p3
WITH p4 EQ p4
WITH p_mailid EQ g_f_mailid
WITH p_psize EQ p_psize
WITH p_psize1 EQ p_psize1
WITH p_psize2 EQ p_psize2
WITH spid EQ g_f_spid
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
VIA JOB g_f_jobname NUMBER g_f_jobcount AND RETURN.
*(3)Job closed when starts Immediately
IF NOT p_imm IS INITIAL.
IF sy-index LE g_f_nojob.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_f_jobcount
jobname = g_f_jobname
strtimmed = g_flg_start
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
gs_jobsts-jobcount = g_f_jobcount.
gs_jobsts-jobname = g_f_jobname.
gs_jobsts-spname = g_f_spname.
APPEND gs_jobsts to gt_jobsts.
ELSEIF sy-index GT g_f_nojob.
CLEAR g_f_flg.
DO. " Wiating untill any job completion
LOOP AT gt_jobsts into gs_jobsts.
CLEAR g_f_status.
CALL FUNCTION 'BP_JOB_STATUS_GET'
EXPORTING
JOBCOUNT = gs_jobsts-jobcount
JOBNAME = gs_jobsts-jobname
IMPORTING
STATUS = g_f_status
* HAS_CHILD =
* EXCEPTIONS
* JOB_DOESNT_EXIST = 1
* UNKNOWN_ERROR = 2
* PARENT_CHILD_INCONSISTENCY = 3
* OTHERS = 4
g_f_mid = gs_jobsts-spname.
IF g_f_status = 'F'.
IMPORT gt_final FROM MEMORY ID g_f_mid .
FREE MEMORY ID gs_jobsts-spname.
APPEND LINES OF gt_final to gt_final1.
REFRESH gt_prlist.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = g_f_jobcount
jobname = g_f_jobname
strtimmed = g_flg_start
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc = 0.
g_f_flg = 'X'.
gs_jobsts1-jobcount = g_f_jobcount.
gs_jobsts1-jobname = g_f_jobname.
gs_jobsts1-spname = g_f_spname.
APPEND gs_jobsts1 TO gt_jobsts.
DELETE TABLE gt_jobsts FROM gs_jobsts.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
IF g_f_flg = 'X'.
CLEAR g_f_flg.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
IF sy-subrc <> 0.
MESSAGE e539(scpr) WITH g_f_jobname.
ENDIF.
COMMIT WORK .
ENDDO. -
How to select the data from a Maintainance View into an internal table
Hi All,
Can anybody tell me how to select the data from a Maintainance View into an internal table.
Thanks,
srinivas.HI,
You can not retrieve data from A mentenance view.
For detail check this link,
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
Regards,
Anirban -
Creating XML file from ABAP internal table data....
Hello,
I am fethcing data froma custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
<batch>
<invoice>
<StatusCode>10</StatusCode>
<paymentamount>122.00</paymentamount>
<ReferenceNumber>70980934</ReferenceNumber>
</invoice>
<invoice>
<StatusCode>90</StatusCode>
<paymentamount>122.00</paymentamount>
<ReferenceNumber>70980934</ReferenceNumber>
</invoice>
<control>
<InvoiceCount>2</InvoiceCount>
</control>
</batch>
Please help.
Regards,
Jainam.I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
Thomas -
Need suggestion in uploading dynamic excel file to corresponding columns of internal table
Hi Friends,
I have an excel file which doesn't have standard template. Just the users will key in their header (in row1 ) and followed by item details in excel and upload to internal table. Now by doing some internal developments in program I need to place the values in corresponding fields.
Let me explain with some examples.
1. I have an internal table
data : begin of itab occurs 0,
f1,
f2,
f3,
f4,
f5,
end of itab.
2. I have excel file as below
3 . Now i need to fill my internal table itab as below
Need to be placed in corresponding fields.
4. When I used GUI_UPLOAD FM it updates internal table as
Please give me suggestion on how to achieve it.
Thanks in advance.Hi Kumar,
use a temporary table to get excel values and then parse them to a second table with the format you want.
This is pretty basic.
regards,
Edgar -
How to populate data in dynamic internal table
Hi Expert,
fyi. My dynamic internal table field is created base on data selected. Eg. select table qpcd has 5 records. These 5 recods will become fieldname to my dynamic internal table. My dynamic internal table will be
...itab
01
02
03
04
05
The 5 records from qpcd is populated in another table call viqmel. I need to find the occurance of each code in viqmel and populate the number of occurance in itab in each of column. The final dynamic itab will be like this
table itab
01 02 03 04 05 -
> field name
2 0 1 0 1 -
> data
my source code like below
Report ZPLYGRND2.
TABLES: mara, makt.
TYPE-POOLS: slis, sydes.
DATA:it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat,
ls_layout TYPE slis_layout_alv.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data,
new_line TYPE REF TO data,
ob_cont_alv TYPE REF TO cl_gui_custom_container,
ob_alv TYPE REF TO cl_gui_alv_grid,
vg_campos(255) TYPE c,
i_campos LIKE TABLE OF vg_campos,
vg_campo(30) TYPE c,
vg_tables(60) TYPE c.
types : begin of t_qpcd,
codegruppe like qpcd-codegruppe,
code like qpcd-code,
end of t_qpcd.
data:wa_qpcd type t_qpcd,
i_qpcd type standard table of t_qpcd initial size 0.
FIELD-SYMBOLS: <l_table> TYPE table,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
select * into corresponding fields of wa_qpcd from qpcd
where katalogart = 'D'
and codegruppe = 'OOT01'.
append wa_qpcd to i_qpcd.
endselect.
loop at i_qpcd into wa_qpcd.
is_fcat-fieldname = wa_qpcd-code.
APPEND is_fcat TO it_fcat.
endloop.
LOOP AT it_fcat INTO is_fcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-ref_fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
*... Create the dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
if sy-subrc = 0.
endif.
*... Create a new line
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
LOOP AT <l_table> INTO <l_line>.
ENDLOOP.hello dear i m giving u a code in this a dynamic table is made on the basis of table in database , and u can download this data correct it , see it, or even change it....and upload in tht table help full if u dont know the table name...in advance.
also the code to populate data in dynamic table is in this code like:
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
look at the whole program .hope this solve ur problem thanks.
REPORT ZTESTA MESSAGE-ID ZIMM .
TYPES : DATA_OBJECT TYPE REF TO DATA.
DATA : MITAB TYPE REF TO DATA .
TYPE-POOLS : SLIS .
DATA : IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
WITH HEADER LINE .
DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT .
DATA : WA_FIELDCATALOG TYPE LVC_S_FCAT .
DATA : I_STRUCTURE_NAME LIKE DD02L-TABNAME .
DATA : I_CALLBACK_PROGRAM LIKE SY-REPID .
DATA : DYN_LINE TYPE DATA_OBJECT .
FIELD-SYMBOLS : <FS_ITAB> TYPE STANDARD TABLE .
DATA : TABLE_NAME_IS_VALID TYPE C .
DATA : DYNAMIC_IT_INSTANTIATED TYPE C .
CONSTANTS BUTTONSELECTED TYPE C VALUE 'X' .
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_TABL.
PARAMETERS : MTABLE_N LIKE RSRD1-TBMA_VAL
MATCHCODE OBJECT DD_DBTB_16 OBLIGATORY .
DATA CHECKTABLED.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_FILE.
PARAMETERS : MFILENAM LIKE RLGRAP-FILENAME .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_DOWN.
PARAMETERS : P_DOWNLD RADIOBUTTON GROUP GRP1
USER-COMMAND M_UCOMM .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_CHKF.
PARAMETERS : P_CHKFIL RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_UPLD.
PARAMETERS : P_UPLOAD RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 5(29) T_SHOW.
PARAMETERS : P_SHOW_T RADIOBUTTON GROUP GRP1 .
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN OUTPUT .
PERFORM CHECK_FILENAME .
AT SELECTION-SCREEN.
IF SY-UCOMM = 'ONLI'.
CHECKTABLED = MTABLE_N+0(1).
IF CHECKTABLED NE 'Z'.
MESSAGE I017.
LEAVE TO SCREEN 1000.
ENDIF.
IF SY-UNAME NE 'KAMESH.K'.
MESSAGE I023 WITH SY-UNAME.
LEAVE TO SCREEN 1000.
ENDIF.
ENDIF.
IF SY-UCOMM = 'PRIN'.
CHECKTABLED = MTABLE_N+0(1).
IF CHECKTABLED NE 'Z'.
MESSAGE I017.
LEAVE TO SCREEN 1000.
ENDIF.
IF SY-UNAME NE 'KAMESH.K'.
MESSAGE I023 WITH SY-UNAME.
LEAVE TO SCREEN 1000.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MFILENAM .
PERFORM F4_FOR_FILENAME .
INITIALIZATION .
T_TABL = 'Table Name' .
T_FILE = 'File Name' .
T_DOWN = 'Download Table' .
T_CHKF = 'Check File to Upload' .
T_UPLD = 'Upload File' .
T_SHOW = 'Show Table Contents' .
START-OF-SELECTION .
PERFORM CHECK_TABLE_NAME_IS_VALID .
END-OF-SELECTION .
IF TABLE_NAME_IS_VALID EQ ' ' .
MESSAGE I398(00) WITH 'INVALID TABLE NAME' .
ELSE .
PERFORM INSTANTIATE_DYNAMIC_INTERNAL_T .
CHECK DYNAMIC_IT_INSTANTIATED = 'X' .
CASE BUTTONSELECTED .
WHEN P_DOWNLD .
PERFORM SELECT_AND_DOWNLOAD .
WHEN P_CHKFIL .
PERFORM CHECK_FILE_TO_UPLOAD .
WHEN P_UPLOAD .
PERFORM UPLOAD_FROM_FILE .
WHEN P_SHOW_T .
PERFORM SHOW_CONTENTS .
ENDCASE .
ENDIF .
FORM CHECK_TABLE_NAME_IS_VALID.
DATA MCOUNT TYPE I .
TABLES DD02L .
CLEAR TABLE_NAME_IS_VALID .
SELECT COUNT(*) INTO MCOUNT FROM TADIR
WHERE PGMID = 'R3TR'
AND OBJECT = 'TABL'
AND OBJ_NAME = MTABLE_N .
IF MCOUNT EQ 1 .
CLEAR DD02L .
SELECT SINGLE * FROM DD02L WHERE TABNAME = MTABLE_N .
IF SY-SUBRC EQ 0.
IF DD02L-TABCLASS = 'TRANSP' .
TABLE_NAME_IS_VALID = 'X' .
ENDIF .
ENDIF.
ENDIF .
ENDFORM. " CHECK_TABLE_NAME_IS_VALID
FORM SELECT_AND_DOWNLOAD.
CLEAR : <FS_ITAB> .
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
PERFORM CHECK_FILENAME.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
IF SY-SUBRC EQ 0.
MESSAGE I398(00) WITH 'Table' MTABLE_N
'successfully downloaded to '
MFILENAM .
ENDIF.
ENDFORM. " SELECT_AND_DOWNLOAD
FORM UPLOAD_FROM_FILE.
DATA : ANS TYPE C .
DATA : LINES_OF_ITAB TYPE I .
DATA : MSY_SUBRC TYPE I .
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
TEXTLINE1 = 'Are you sure you wish to upload'
TEXTLINE2 = 'data from ASCII File to DB table '
TITEL = 'Confirmation of Data Upload'
IMPORTING
ANSWER = ANS.
IF ANS = 'J' .
PERFORM CHECK_FILENAME.
CLEAR MSY_SUBRC .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
IF SY-SUBRC EQ 0.
DESCRIBE TABLE <FS_ITAB> LINES LINES_OF_ITAB .
IF LINES_OF_ITAB GT 0 .
MODIFY (MTABLE_N) FROM TABLE <FS_ITAB> .
MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
ENDIF .
ENDIF.
IF MSY_SUBRC EQ 0 .
MESSAGE I398(00) WITH LINES_OF_ITAB
'Record(s) inserted in table'
MTABLE_N .
ELSE .
MESSAGE I398(00) WITH
'Errors occurred No Records inserted in table'
MTABLE_N .
ENDIF .
ENDIF .
ENDFORM. " UPLOAD_FROM_FILE
FORM F4_FOR_FILENAME.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = 'C:\'
MASK = ',.,..'
MODE = '0'
IMPORTING
FILENAME = MFILENAM
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " F4_FOR_FILENAME
FORM CHECK_FILENAME.
IF MFILENAM IS INITIAL
AND NOT ( MTABLE_N IS INITIAL )
AND P_SHOW_T NE BUTTONSELECTED.
CONCATENATE 'C:\'
MTABLE_N '.TXT' INTO MFILENAM.
ENDIF .
ENDFORM. " CHECK_FILENAME
FORM INSTANTIATE_DYNAMIC_INTERNAL_T.
CLEAR DYNAMIC_IT_INSTANTIATED .
I_STRUCTURE_NAME = MTABLE_N .
CLEAR IT_FIELDCAT[] .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = I_STRUCTURE_NAME
CHANGING
CT_FIELDCAT = IT_FIELDCAT[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC EQ 0.
LOOP AT IT_FIELDCAT .
CLEAR WA_FIELDCATALOG .
MOVE-CORRESPONDING IT_FIELDCAT TO WA_FIELDCATALOG .
WA_FIELDCATALOG-REF_FIELD = IT_FIELDCAT-FIELDNAME .
WA_FIELDCATALOG-REF_TABLE = MTABLE_N .
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG .
ENDLOOP .
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCATALOG
IMPORTING
EP_TABLE = MITAB .
ASSIGN MITAB->* TO <FS_ITAB> .
DYNAMIC_IT_INSTANTIATED = 'X' .
ENDIF.
ENDFORM. " INSTANTIATE_DYNAMIC_INTERNAL_T
FORM SHOW_CONTENTS.
CLEAR : <FS_ITAB> .
SELECT * FROM (MTABLE_N)
INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
I_CALLBACK_PROGRAM = SY-REPID .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = <FS_ITAB>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " SHOW_CONTENTS
FORM CHECK_FILE_TO_UPLOAD.
PERFORM CHECK_FILENAME.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = MFILENAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = <FS_ITAB>
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
IF SY-SUBRC EQ 0.
I_CALLBACK_PROGRAM = SY-REPID .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = <FS_ITAB>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF .
ENDFORM. " CHECK_FILE_TO_UPLOAD
Message was edited by:
SAURABH SINGH
SENIOR EXECUTIVE
SAMSUNG INDIA ELECTRONICS LTD.,NOIDA -
How to upload a file in application server to an internal table
Hi,
I am asked to upload a file from application server to internal table. Can you please suggest me the ways to do it or the function module which helps to browse the application server file names.
I have done a program. But its giving problem in searching the files from application server. I am pasting my code for ur review. Please tell me which part i have to correct or suggest me some other ways to do it.
*& Report ZUPLOAD1
REPORT ZUPLOAD1.
type-pools: truxs.
parameters: p_upl_ps radiobutton group g1 default 'X', "upload from pres. server
p_path type rlgrap-filename,
p_upl_as radiobutton group g1, "upload from appln server
<b>p_dir LIKE filepath-pathintern DEFAULT 'Y_ABAP',
p_file LIKE filepath-pathintern lower case,</b>
p_test as checkbox.
constants: c_x value 'X',
c_tab type c value cl_abap_char_utilities=>horizontal_tab.
types: ty_data(1000) type c. "structure to hold legacy data
data: i_data type standard table of ty_data. "internal table of ty_data
types: begin of stritab,
land1 type v_t604-land1, "structure of legacy file.
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of stritab.
data: gi_itab type standard table of stritab, "internal table of legacy file
gw_itab type stritab. "work area
data: i_raw type truxs_t_text_data,
v_fullpath type string.
at selection-screen on value-request for p_path.
if p_upl_ps = c_x. "if presentation server is selected
perform get_file.
else. "if application server is selected
perform set_file_path.
perform upload_from_server.
perform split_data.
endif.
form get_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_path. "getting the file name of pres server
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X' "converting excel to sap and filling in
I_TAB_RAW_DATA = i_raw "internal table
I_FILENAME = p_path
TABLES
I_TAB_CONVERTED_DATA = gi_itab
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
form set_file_path. "Getting the file path of application server
data: lv_file type p_file.
lv_file = p_file.
CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_PATH = p_dir
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = ' '
PARAMETER_2 = ' '
PARAMETER_3 = ' '
USE_BUFFER = ' '
FILE_NAME = lv_file
USE_PRESENTATION_SERVER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
FILE_NAME_WITH_PATH = v_fullpath
EXCEPTIONS
PATH_NOT_FOUND = 1
MISSING_PARAMETER = 2
OPERATING_SYSTEM_NOT_FOUND = 3
FILE_SYSTEM_NOT_FOUND = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
form upload_from_server.
data: lv_msg type string,
lw_data type ty_data.
open dataset v_fullpath for input message lv_msg in text mode encoding default.
if sy-subrc <> 0.
message lv_msg type 'i'.
stop.
endif.
do.
read dataset v_fullpath into lw_data.
if sy-subrc <> 0.
write:/5 'Error in processign data set'.
exit.
endif.
append lw_data to i_data.
enddo.
close dataset v_fullpath.
if sy-subrc <> 0.
write: /5 'Error closing dataset'.
endif.
endform.
form split_data.
data: lw_data type ty_data.
data: lw_itab type stritab.
data: begin of ty_itab,
land1 type v_t604-land1,
stawn type v_t604-stawn,
bemeh type v_t604-bemeh,
impma type v_t604-impma,
minol type v_t604-minol,
end of ty_itab.
loop at i_data into lw_data.
split lw_data at c_tab into
ty_itab-land1
ty_itab-stawn
ty_itab-bemeh
ty_itab-impma
ty_itab-minol.
lw_itab-land1 = ty_itab-land1.
lw_itab-stawn = ty_itab-stawn.
lw_itab-bemeh = ty_itab-bemeh.
lw_itab-impma = ty_itab-impma.
lw_itab-minol = ty_itab-minol.
append lw_itab to gi_itab.
endloop.
endform.
start-of-selection.
loop at gi_itab into gw_itab.
write: /5 'COUNTRY', 'IMPORT CODE', 'SUP UNIT', 'FIRST UOM', 'SECOND UOM',
/5 gw_itab-land1, gw_itab-stawn,gw_itab-bemeh,gw_itab-impma,gw_itab-minol.
endloop.
end-of-selection.
I hope problem must be in p_dir and p_file which are in bold.. Kindly help me out. Thanks in advance.see the following ex:
*& Form SUB_GET_FILEPATH
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILEPATH .
GFILE = 'D:\SAP_INT\INBOUND\INBOX'. "Path
ENDFORM. " SUB_GET_FILEPATH
*& Form SUB_GET_FILE
text
--> p1 text
<-- p2 text
FORM SUB_GET_FILE .
DATA: P_FDIR(200) TYPE C.
DATA: IT_FILEDIR1 TYPE STANDARD TABLE OF TY_FILEDIR WITH HEADER LINE.
P_FDIR = GFILE.
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
NAME = P_FDIR
TABLES
FILE_TBL = IT_FILEDIR.
REFRESH : IT_FILEDIR1.
LOOP AT IT_FILEDIR.
IF IT_FILEDIR-NAME(4) = 'ZINC' OR IT_FILEDIR-NAME(4) = 'zinc'.
MOVE IT_FILEDIR-NAME TO IT_FILEDIR1-NAME.
APPEND IT_FILEDIR1.
ENDIF.
ENDLOOP.
IF IT_FILEDIR1[] IS INITIAL.
STOP.
ENDIF.
LOOP AT IT_FILEDIR1.
REFRESH: I_TAB.
CLEAR: I_TAB.
NAME = IT_FILEDIR1-NAME.
CONCATENATE: GFILE '\' NAME INTO G_FILE.
OPEN DATASET G_FILE FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
CONCATENATE 'FILENAME : ' G_FILE INTO I_MSG1.
APPEND I_MSG1.
DO.
READ DATASET G_FILE INTO RECORD.
IF SY-SUBRC = 0.
SPLIT RECORD AT ',' INTO I_TAB-BUKRS I_TAB-EBELN
I_TAB-BLDAT I_TAB-XBLNR I_TAB-LIFNR I_TAB-AMOUNT
I_TAB-CURR I_TAB-BUSAREA
I_TAB-BKTXT I_TAB-DMBTR I_TAB-MENGE I_TAB-SRNO.
MOVE-CORRESPONDING I_TAB TO I_TAB1.
ELSE.
EXIT.
ENDIF.
APPEND I_TAB1.
CLEAR: I_TAB, I_TAB1.
ENDDO.
ENDIF.
CLOSE DATASET G_FILE.
Maybe you are looking for
-
Trick to add all clips to timeline?
I just finished a project, and created a new sequence to dump all of my raw footage into so I can encode that for DVD, since they want the raw footage as well. So when I select all my clips in the bin and drag them to the timeline, it obviously keeps
-
Search and find jpg files with uppercase extension
Macbook pro 13 inch retina display with OS X Yosemite. Some of the images I'm working on are being saved with all uppercase extension .JPG. My questions is: 1) Does anyone know why this is happening? 2) Is there a way to search all the files that hav
-
Dear All Any suggestions ? Currently when we try and transport requests between systems, the transports are getting 'stuck' in the delivery stage (Truck icon) and not moving. I can add transport fine at unix level, all the RFC checks are ok. All the
-
I just had to download Firefox so that I could communicate with Chase's website. They told me over the phone that they won't accept Safari traffic anymore and they told me to download Firefox. Also, songboxes on Myspace have disappeared when using Sa
-
Help me with restore the macbook pro
how to restore my os x lion when i'v install os x mountain lion pls help me