Exit in itab.
Hello everyone,
I like to know as to How we can exit from multiple loops using single exit inside the loop.
i pasted the code below. I just want to exit out of both the loops and i dont want to use onemore exit or stop there.
REPORT zmadhu_temp.
TABLES: mara, makt.
DATA: BEGIN OF itab1 OCCURS 0.
INCLUDE STRUCTURE mara.
DATA: END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0.
INCLUDE STRUCTURE makt.
DATA: END OF itab2.
SELECT * FROM mara INTO TABLE itab1 UP TO 10 ROWS.
SELECT * FROM makt INTO TABLE itab2 FOR ALL ENTRIES IN itab1 WHERE matnr = itab1-matnr.
LOOP AT itab1.
LOOP AT itab2.
EXIT.
ENDLOOP.
ENDLOOP.
hi,
with one exit you can not come out from 2 loops except the case the first loop is processing the last record.
sudheer.A
Message was edited by:
sudheer Addepalli
Similar Messages
-
HI,
I use that function for alv and fieldcat and its working o.k. but i wont to add
field name to colman and its not working ,and optimaize colman for text , and title how i do that?
Regards
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-fix_column = &3. "this is not working
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DATA l_rnd_value TYPE integer2.
FIELD-SYMBOLS : <itab> LIKE LINE OF itab .
LOOP AT itab ASSIGNING <itab>.
CASE <itab>-object.
WHEN 'Badi'.
<itab>-line_color = 'C510'. " Blue.
WHEN 'User Exit'.
<itab>-line_color = 'C611'. " Red.
ENDCASE.
ENDLOOP.
ENDFORM.
FORM f_display_data.
DATA:
ls_layout TYPE slis_layout_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'OBJECT' 'ITAB' 'X'.
m_fieldcat 'OBJECT_NAME' 'ITAB' 'X' .
* m_fieldcat 'VBELN' 'VBAK'.
* m_fieldcat 'NETWR' 'VBAK'.
* Fill Layout - Name of the field with color
ls_layout-info_fieldname = 'LINE_COLOR'.
* Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = itab.
ENDFORM. "f_display_dataYou will have to use this:
1. Change the macro following way:
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-fix_column = &3.
ls_fieldcat-reptext_ddic = &4. " << will repalce from the macro's argument
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
2. Call the macro like this.
m_fieldcat 'OBJECT' 'ITAB' 'X' 'Object'
m_fieldcat 'OBJECT_NAME' 'ITAB' 'X' 'Oject Name'.
Regards,
Naimesh Patel -
Hi all,
i am getting an output like below.
S3080 BE EUR 0000023000 0000000000
B0301 BE EUR 0000000000 0000000048
but i need the output like this
S3080;BE;EUR;23000;0
B0301;BE;EUR;0;48
How can i do this?.
Regards,
LisaHai Lisa
S3080 BE EUR 0000023000 0000000000
B0301 BE EUR 0000000000 0000000048
take internal table fields like this
AAAA BBBB CCCC DDDD EEEE
loop at itab.
write : / itab-AAAA,
itab-BBBB,
itab-CCCC,
if itab-DDDD ca '1'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '2'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '3'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '4'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '5'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '6'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '7'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '8'.
write : itab-DDDD+5(5),
exit.
elseif itab-DDDD ca '9'.
write : itab-DDDD+5(5),
exit.
else.
write : '0',
endif.
if itab-EEEE ca '1'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '2'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '3'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '4'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '5'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '6'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '7'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '8'.
write : itab-EEEE+8(2).
exit.
elseif itab-EEEE ca '9'.
write : itab-EEEE+8(2).
exit.
else.
write : '0'.
endloop.
Thanks & regards
Sreenivasulu P -
Import itab in memory in user exit
I am trying to export an internal table to memory in BADI and import from memory into an internal table in User exit . It looks like the export works, but when I import in program2, the internal table is empty. Even when the command returns sy-subrc = 0.
Has anyone made this work?
Program1
DATA: wa_medoc LIKE MEASUREMENT_DOC.
DATA: WA_TEXT LIKE LINE OF CE_MEASUREMENT.
TYPES: BEGIN OF obj_line,
MEASUREMENT_POINT(12) ,
READING_DATE(8),
READING_TIME(6),
RECORDED_UNIT(6),
LONG_TEXT(16384),
END OF obj_line.
DATA: obj_tab_wa TYPE obj_line.
Move: MEASUREMENT_DOC to wa_medoc.
LOOP AT CE_MEASUREMENT INTO WA_TEXT.
MOVE: wa_medoc-MEASUREMENT_POINt TO obj_tab_wa-MEASUREMENT_POINT,
wa_medoc-READING_DATE TO obj_tab_wa-READING_DATE ,
wa_medoc-READING_TIME TO obj_tab_wa-READING_TIME,
wa_medoc-RECORDED_UNIT TO obj_tab_wa-RECORDED_UNIT,
WA_TEXT-LONG_TEXT TO obj_tab_wa-LONG_TEXT.
EXPORT obj_line FROM obj_tab_wa TO MEMORY ID 'SQ'.
ENDLOOP.
Program 2 : User exit EXIT_SAPLIMR0_001 and include ZXMRCU01.
TYPES: BEGIN OF obj_line,
MEASUREMENT_POINT(12) ,
READING_DATE(8),
READING_TIME(6),
RECORDED_UNIT(6),
LONG_TEXT(16384),
END OF obj_line.
DATA: obj_tab_wa TYPE obj_line.
IMPORT obj_line FROM MEMORY ID 'SQ'.Try this......
Program1
DATA: wa_medoc LIKE MEASUREMENT_DOC.
DATA: WA_TEXT LIKE LINE OF CE_MEASUREMENT.
TYPES: BEGIN OF obj_line,
MEASUREMENT_POINT(12) ,
READING_DATE(8),
READING_TIME(6),
RECORDED_UNIT(6),
LONG_TEXT(16384),
END OF obj_line.
DATA: obj_tab_wa TYPE obj_line.
data: obj_tab_tab type standard table of obj_line.
Move: MEASUREMENT_DOC to wa_medoc.
LOOP AT CE_MEASUREMENT INTO WA_TEXT.
MOVE: wa_medoc-MEASUREMENT_POINt TO obj_tab_wa-MEASUREMENT_POINT,
wa_medoc-READING_DATE TO obj_tab_wa-READING_DATE ,
wa_medoc-READING_TIME TO obj_tab_wa-READING_TIME,
wa_medoc-RECORDED_UNIT TO obj_tab_wa-RECORDED_UNIT,
WA_TEXT-LONG_TEXT TO obj_tab_wa-LONG_TEXT.
append obj_tab_wa to obj_tab_tab.
ENDLOOP.
if sy-subrc = 0.
EXPORT obj_tab_tab[] TO MEMORY ID 'SQ'.
endif.
Program 2 : User exit EXIT_SAPLIMR0_001 and include ZXMRCU01.
TYPES: BEGIN OF obj_line,
MEASUREMENT_POINT(12) ,
READING_DATE(8),
READING_TIME(6),
RECORDED_UNIT(6),
LONG_TEXT(16384),
END OF obj_line.
DATA: obj_tab_wa TYPE obj_line.
data: obj_tab_tab type standard table of obj_line.
IMPORT obj_tab_tab[] FROM MEMORY ID 'SQ'.
Edited by: Joyjit Ghosh on Jul 8, 2008 2:22 PM -
Delete Itab within Loop at ITAB ?
Hi,
Help needed to remove this delete from within the loop.
{code
Loop at itab where <condition>.
<statements>
delete itab index sy-tabix.
Exit.
Endloop.
{code}
The functionality of the code should not be affected.
Useful help would be awardedHi,
Instead of deleting data from itab use another internal table of same type (itab1) and append it. Use itab1 data for further processing.
check below logic...
{code
Loop at itab1 into wa_itab1 where <condition>.
<statements>
if <condition>
append wa_itab1 to itab2.
exit.
endif.
Endloop.
refresh itab1.
itab1[] = itab2[].
{code}
regards,
N M Poojari. -
Excel Upload and moving the data to dynamic itab
Hi Folks,
I am building a fieldcatalog dynamically based on the table name and then creating a dynamic internal table based on the fieldcatalog.Now I have a excel sheet having the fields in the same structure as the fieldcatalog that I built.I want to upload the data in the excel to an internal table having the structure of the fieldcatalog I built.I am having a problem in moving the data from the excel to the itab (dynamic itab built based on the fieldcatalog)
1.Building the fieldcatalog.
data:gt_fieldcat TYPE lvc_t_fcat.
ls_fieldcat-tabname = p_tabname.
ls_fieldcat-fieldname = p_fieldname.
ls_fieldcat-inttype = 'C'.
ls_fieldcat-outputlen = wa_dfies-outputlen.
ls_fieldcat-coltext = wa_dfies-fieldtext.
APPEND: ls_fieldcat TO gt_fieldcat.
CLEAR : ls_fieldcat.
2.Building the dynamic itab
DATA:gp_table TYPE REF TO data.
FIELD-SYMBOLS: <gt_table> TYPE table,
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_table.
ASSIGN gp_table->* TO <gt_table>.
3.Now I have an excel with a similar structure with data.Uploading the excel data into itab.
DATA: g_t_xltab TYPE STANDARD TABLE OF ty_xltab,
it_rawdata TYPE truxs_t_text_data,
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_rawdata
i_filename = xls_filename
TABLES
i_tab_converted_data = g_t_xltab[]
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.
*Move the data that got uploaded from excel into
*respective internal tables.
LOOP AT g_t_xltab
here I want move the data into an internal table having the structure I built using
the fieldcatalog/dynamic itab ie <gt_table>.
Endloop.
I tried using ASSIGN COMPONENT sy-index of <gt_table> and move-corresponding but in vain as I am not that much familiar with dynamic itab using field symbols.Kindly let me know how the excel data can be moved to dynamic itab.
Thanks,
K.Kiran.Hi,
you can try some logic like this. Please note this is just an example
TYPE-POOLS:truxs.
TYPES:BEGIN OF ty_xltab,
field TYPE string,
END OF ty_xltab.
DATA:wa TYPE ty_xltab.
DATA:lv_len TYPE i.
DATA:startpos TYPE i.
FIELD-SYMBOLS:<fs_line> TYPE mara.
FIELD-SYMBOLS:<fs> TYPE ANY.
DATA: g_t_xltab TYPE STANDARD TABLE OF ty_xltab,
it_rawdata TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_rawdata
i_filename = ' '
TABLES
i_tab_converted_data = g_t_xltab[]
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.
startpos = 0.
LOOP AT g_t_xltab INTO wa.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_line> TO <fs>.
IF sy-subrc = 0.
DESCRIBE FIELD <fs> OUTPUT-LENGTH lv_len.
IF lv_len > 0.
<fs> = wa-field+startpos(lv_len).
startpos = startpos + lv_len.
ENDIF.
ELSE.
append <fs_line> to <fs_tab>.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
Sorry my answer is not for you requirement..Please Ignore.
Your solution can be easily solved by looking at the concept Assign component . Please search
Edited by: Keshav.T on Nov 7, 2011 1:42 PM -
Hello All,
A code has been written in the User exit for Tcode ME22N, Which sets the indicator on PO line item. This has been done by modifying the standard itab POT by using field symbols, because the fields to be modified are shown in display mode in the tcode ME22N and cannot be done in BDC. See the below code in user exit ZXM06U43.
DATA char(50) VALUE '(SAPLMEPO)POT[]'.
CLEAR wa_ind.
FIELD-SYMBOLS <f1> TYPE ANY.
Move memory of internal table POT to field symbol f1.
ASSIGN (char) TO <f1>.
Move content of f1 to internal table i_ind
i_ind[] = <f1> .
LOOP AT i_ind INTO wa_ind.
IF wa_ind-pstyp = '9'. " Service PO - item category
IF PO Line item has History per Purchasing Document as 'D'
Set indicators on, for the line item.
CLEAR v_cnt.
SELECT COUNT( * ) INTO v_cnt FROM ent5100
WHERE ebeln = wa_ind-ebeln
AND ebelp = wa_ind-ebelp
AND bewtp = 'D'.
IF sy-subrc = 0.
wa_ind-wepos = 'X'. " Set Goods Receipt Indicator
wa_ind-webre = 'X'. " Set GR-based IV Indicator
wa_ind-lebre = 'X'. " Set Srv-based IV Indicator
ELSE.
*End of addition SAP-20070910104025 - SL36 - D01K963369
wa_ind-wepos = ' '. " Clear Goods Receipt Indicator
wa_ind-webre = ' '. " Clear GR-based IV Indicator
wa_ind-lebre = ' '. " Clear Srv-based IV Indicator
wa_ind-xersy = ' '. " Clear ERS Indicator
ENDIF.
MODIFY i_ind FROM wa_ind INDEX sy-tabix.
ENDIF.
ENDLOOP.
<f1> = i_ind[].
ENDIF.
ENDIF.
This code is in production and has been working fine.
The requirnment is now to make this indicator work for all the Purchase order before this code has been written in the Exit. For this my functional suggests that to write a separate program using BDC for PO change and jus add a period/dot in the short text and save it. The code has been written, the user exit and the above code is getting triggrred values are updated in internal table correctly.
However the flags was not set or cleared when seen in the tcode ME22N . This works fine if the tcode me22n is run directly and not working in BDC.
I have tried with ME22 without enjoy transaction in BDC changing the POT Program to SAPMM06E. It does not work.
Please help me as why it is not uodating in the table when using BDC.
Thanks in Advance.
Senthil KumarHi All,
Any luck on this??
Thanks -
Data from itab to be store in text file in desktop
hi
i am tyring to store the data from itab into a text file in desktop,but its now owrking.
i am using open dataset statment,but no where data is storing.My code:
TYPES : BEGIN OF ST_DEMO,
REG_NO(10) TYPE C,
NAME(20) TYPE C,
ADDR(20) TYPE C,
END OF ST_DEMO.
DATA : WA_DEMO TYPE ST_DEMO,
IT_DEMO TYPE TABLE OF ST_DEMO,
L_FNAME TYPE dxfile-filename .
PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\put\vipin.txt' OBLIGATORY.
L_FNAME = P_FNAME.
WA_DEMO-REG_NO = '100001'.
WA_DEMO-NAME = 'ANAND'.
WA_DEMO-ADDR = 'NAGARKOVIL'.
APPEND WA_DEMO TO IT_DEMO.
OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
LOOP AT IT_DEMO INTO WA_DEMO.
IF SY-SUBRC = 0.
TRANSFER WA_DEMO TO L_FNAME.
WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
ENDIF.
ENDLOOP.
close DATASET L_FNAME.
please tell me where is the prob?I wan to schedule it for background job.
regds
vipinhi
here is the code for : "data from itab to be store in text file in desktop"
TABLES: vbak. " standard table
* Type Pools *
TYPE-POOLS: slis.
* Global Structure Definitions *
*-- Structure to hold data from table CE1MCK2
TYPES: BEGIN OF tp_itab1,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
werks LIKE vbap-werks,
lgort LIKE vbap-lgort,
END OF tp_itab1.
*-- Data Declaration
DATA: t_itab1 TYPE TABLE OF tp_itab1.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
* Selection Screen *
*--Sales document-block
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN END OF BLOCK b1.
*--Display option - block
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
PARAMETERS: alv_list RADIOBUTTON GROUP g1,
alv_grid RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b2.
*file download - block
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
PARAMETERS: topc AS CHECKBOX,
p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK b3.
* Initialization. *
* At Selection Screen *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-cprog
dynumb = sy-dynnr
filetype = 'P' "P-->Physical
location = 'P' "P Presentation Srever
server = space.
AT SELECTION-SCREEN ON s_vbeln.
PERFORM vbeln_validate.
* Start Of Selection *
START-OF-SELECTION.
*-- Fetching all the required data into the internal table
PERFORM select_data.
* End Of Selection *
END-OF-SELECTION.
IF t_itab1[] IS NOT INITIAL.
IF topc IS NOT INITIAL.
PERFORM download.
MESSAGE 'Data Download Completed' TYPE 'S'.
ENDIF.
PERFORM display.
ELSE.
MESSAGE 'No Records Found' TYPE 'I'.
ENDIF.
* Top Of Page Event *
TOP-OF-PAGE.
*& Form : select_data
* Description : Fetching all the data into the internal tables
* parameters : none
FORM select_data .
SELECT vbeln
posnr
werks
lgort
INTO CORRESPONDING FIELDS OF TABLE t_itab1
FROM vbap
WHERE vbeln IN s_vbeln.
IF sy-subrc <> 0.
MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
EXIT.
ENDIF.
ENDFORM. " select_data
*& Form : display
* decription : to display data in given format
* parameters : none
FORM display .
IF alv_list = 'X'.
PERFORM build_fieldcat TABLES i_fieldcat[]
USING :
*-Output-field Table Len Ref fld Ref tab Heading Col_pos
'VBELN' 'T_ITAB1' 10 'VBAP' 'VBELN' '' 1,
'POSNR' 'T_ITAB1' 6 'VBAP' 'POSNR' '' 2,
'WERKS' 'T_ITAB1' 4 'VBAP' 'WERKS' '' 3,
'LGORT' 'T_ITAB1' 4 'VBAP' 'LGORT' '' 4.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* i_callback_pf_status_set = c_pf_status
i_callback_user_command = 'USER_COMMAND '
* it_events = t_alv_events[]
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = t_itab1[]
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.
ENDIF.
IF alv_grid = 'X'.
PERFORM build_fieldcat TABLES i_fieldcat[]
USING :
*-Output-field Table Len Ref fld Ref tab Heading Col_pos
'VBELN' 'T_ITAB1' 10 'VBAP' 'VBELN' '' 1,
'POSNR' 'T_ITAB1' 6 'VBAP' 'POSNR' '' 2,
'WERKS' 'T_ITAB1' 4 'VBAP' 'WERKS' '' 3,
'LGORT' 'T_ITAB1' 4 'VBAP' 'LGORT' '' 4.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* i_callback_pf_status_set = c_pf_status
i_callback_user_command = 'USER_COMMAND '
it_fieldcat = i_fieldcat
TABLES
t_outtab = t_itab1[]
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.
ENDIF.
ENDFORM. " display
*& Form : vbeln_validate
* description : to validate sales document number
* parameters : none
FORM vbeln_validate .
DATA: l_vbeln TYPE vbak-vbeln.
SELECT SINGLE vbeln
FROM vbak
INTO l_vbeln
WHERE vbeln IN s_vbeln.
IF sy-subrc NE 0.
MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
EXIT.
ENDIF.
ENDFORM. " vbeln_validate
*& Form :build_fieldcat
* Description : This routine fills field-catalogue
* Prameters : none
FORM build_fieldcat TABLES fpt_fieldcat TYPE slis_t_fieldcat_alv
USING fp_field TYPE slis_fieldname
fp_table TYPE slis_tabname
fp_length TYPE dd03p-outputlen
fp_ref_tab TYPE dd03p-tabname
fp_ref_fld TYPE dd03p-fieldname
fp_seltext TYPE dd03p-scrtext_l
fp_col_pos TYPE sy-cucol.
*-- Local data declaration
DATA: wl_fieldcat TYPE slis_fieldcat_alv.
*-- Clear WorkArea
wl_fieldcat-fieldname = fp_field.
wl_fieldcat-tabname = fp_table.
wl_fieldcat-outputlen = fp_length.
wl_fieldcat-ref_tabname = fp_ref_tab.
wl_fieldcat-ref_fieldname = fp_ref_fld.
wl_fieldcat-seltext_l = fp_seltext.
wl_fieldcat-col_pos = fp_col_pos.
*-- Update Field Catalog Table
APPEND wl_fieldcat TO fpt_fieldcat.
ENDFORM. "build_fieldcat
*& Form : download
* description : To Download The Data
* Parameters : none
FORM download .
DATA: l_file TYPE string.
l_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
TABLES
data_tab = t_itab1
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6.
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. " download
hope it will help you
regards
rahul -
Upload XML file from server to itab
After failed to get a answer about download data from xml file in server to my itab, and searching and searching in hundred of post and threads i try my own solution for this issue.
I read the file with:
OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
In this case the result is a table filled with register type string like this:
#<label>22222</label>
I need a table with this kind of value (example):
label | 22222
label2 | John
label3 | Smith
Therefore i have to parse the data of my table, i try with the FM:
TEXT_CONVERT_XML_TO_SAP
But dont works for me,
I am too new in ABAP.
The code for my report is very simple:
REPORT ZPRUEBA_XML.
DATA: BEGIN OF TABLA OCCURS 1,
TEXTO(256) TYPE C,
END OF TABLA.
DATA: FICHERO LIKE RLGRAP-FILENAME.
OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE:/ 'ERROR'.
ENDIF.
FREE TABLA.
DO.
READ DATASET FICHERO INTO TABLA.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
APPEND TABLA.
WRITE: TABLA-TEXTO.
ENDIF.
ENDDO.
CLOSE DATASET FICHERO.
And my ".xml" in the server is very simple too.
<label>222222</label>
<name>John</name>
<street>Smith, 23, NY</street>
Anyone can help me?
ThanksHi,
You could use a transformation to do that, or call FM 'TEXT_CONVERT_XML_TO_SAP'... you also have the class IF_IXML that should help you and a lot of threads on the subject, such as:
convert XML data into ABAP internal table
ABAP Class to convert XML to itab
Upload XML to internal table and vice versa in SAP 4.6C
http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e66701fc-0d01-0010-9c9a-f8a36c4e87ba
Kr,
Manu. -
AIST0002-User Exit - Validation of user defined field
I have implemented the enhancement aist0002. I added a user defined field in a user defined subcreen and added it to the leasing tabstrip. I would like to validate this field against a another field in sap's leasing subscreen. In the pai of the user defined subsrceen the field of the other subscreen does not get filled. Is there a way to access the field of the other subscreen on the leasing tabstrip from the pai module of the user defined subscreen?
Thank you
TomThank you for your response but I am not sure where the import occurs?
This is the pai of the user subscreen 9000 for AS01.
form edit_input .
data: itab type lfza.
if anlu-zzempfk is not initial.
select * from lfza into itab
where empfk = anlu-zzempfk and
lifnr = anla-leafi.
endselect.
if sy-subrc <> 0.
set cursor field 'ANLU-ZZEMPFK'.
message e007(zvalid).
endif.
endif.
endform.
Function exit EXIT_SAPLAIST_002 include zxaisu03
looks like this:
anlu = i_anlu.
anla = i_anla.
Data gets moved to anlu or anla if it was already built. They are empty when it is a create transaction(as01).
Function exit exit_saplaist_003. include zxaisu04
looks like this:
e_anlu = anlu.
After the subscreen is processed it exports the data to global variable.
The problem is the pai module for the user subscreen 9000, the field anla-leafi is not filled. This field is located in sap's subsceen 1403. It has data in the screen field. My assumption is that it would be accessible as global data that could be used by my user defined subscreen once I began the validation in the pai of subscreen 9000.
Could you provide more insight on how I would access the field from the other subscreen? -
Required User Exit Or Badi.
Hi Friends,
I am searching for the user exit or Badi .
The scenario is:- First i create a Purchase Requisition
in ME51N. After creating the PR, the transaction ME59 is run which automatically creates Purchase order from the PR. The automatic creation of PO from PR is done by the user exit or Badi.
Please tell me the Badi or user exit.
Points will given to useful response.
Regards,
Mandeep.Hi Mandeep, this is BADI for ME51N.
report ZUDAY_BDC_TCL1 no standard page heading line-size 255.
include bdcrecx1.
TABLES EBAN.
DATA: BEGIN OF ITAB OCCURS 0,
NUMBER(3) TYPE C,
MATNR LIKE EBAN-MATNR,
TXZ01 LIKE EBAN-TXZ01,
MENGE(13) TYPE C,
MEINS LIKE EBAN-MEINS,
EEIND TYPE RM06B-EEIND,
EKGRP LIKE EBAN-EKGRP,
MATKL LIKE EBAN-MATKL,
WERKS(4) TYPE C,
END OF ITAB.
DATA: LVALUE TYPE I,
COUNT TYPE I,
TEMP(20) TYPE C,
CTRL TYPE I,
CTRL1(3) TYPE C,
PAGES(5) TYPE c VALUE '10',
PVALUE(3) TYPE C VALUE 0.
start-of-selection.
PERFORM GETDATA.
SORT ITAB BY NUMBER.
perform open_group.
LOOP AT ITAB.
IF ITAB-NUMBER <> LVALUE.
COUNT = 0.
perform bdc_dynpro using 'SAPMM06B' '0100'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-BSART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-BSART'
'NB'.
perform bdc_field using 'RM06B-LPEIN'
'T'.
perform bdc_field using 'EBAN-EKGRP'
'008'.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MATNR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
PAGES = 10.
CTRL = 0.
LOOP AT ITAB WHERE NUMBER = ITAB-NUMBER.
CTRL = CTRL + 1.
IF CTRL >= 19.
PAGES = PAGES + 10.
ENDIF.
CTRL1 = CTRL.
IF CTRL >= 19.
CTRL1 = '19'.
ENDIF.
IF CTRL >= 10.
PVALUE = ''.
ENDIF.
perform bdc_field using 'RM06B-BNFPO'
PAGES.
Concatenate 'EBAN-MATNR(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-MATNR.
Concatenate 'EBAN-TXZ01(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-TXZ01.
Concatenate 'EBAN-MENGE(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-MENGE.
Concatenate 'EBAN-MEINS(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-MEINS.
Concatenate 'RM06B-EEIND(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-EEIND.
Concatenate 'EBAN-EKGRP(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-EKGRP.
Concatenate 'EBAN-MATKL(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-MATKL.
Concatenate 'EBAN-WERKS(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using Temp itab-WERKS.
perform bdc_dynpro using 'SAPMM06B' '0102'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-TXZ01'
ITAB-TXZ01. "'HD GLAD BOY tank silver'.
perform bdc_field using 'EBAN-MENGE'
ITAB-MENGE. "'500'.
perform bdc_field using 'RM06B-EEIND'
ITAB-EEIND."'27.06.2007'.
perform bdc_field using 'EBAN-EKGRP'
ITAB-EKGRP. "'001'.
perform bdc_field using 'EBAN-BADAT'
'15.06.2007'.
perform bdc_field using 'EBAN-FRGDT'
'26.06.2007'.
perform bdc_field using 'EBAN-PREIS'
'55.48'.
perform bdc_field using 'EBAN-WAERS'
'GBP'.
perform bdc_field using 'EBAN-PEINH'
'1'.
perform bdc_field using 'EBAN-REPOS'
'X'.
perform bdc_dynpro using 'SAPMM06B' '0106'.
Concatenate 'ElBAN-MATNR(' PVALUE CTRL1 ')' into Temp.
CONDENSE Temp NO-GAPS.
perform bdc_field using 'BDC_CURSOR' Temp.
perform bdc_field using 'BDC_OKCODE'
'/00'.
ENDLOOP.
LVALUE = ITAB-NUMBER.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RM06B-BNFPO'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'RM06B-BNFPO'
'80'.
*AT END OF NUMBER.
perform bdc_transaction using 'ME51'.
REFRESH BDCDATA.
*ENDAT.
ENDIF.
ENDLOOP.
perform close_group.
*& Form GETDATA
text
--> p1 text
<-- p2 text
FORM GETDATA .
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = ' '
FILETYPE = ' '
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
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. " GETDATA.
kindly reward if found helpful.
cheers,
Hema. -
Help needed regarding SUM keyword in an ITAB loop
Hello,
I am maintaining a code as given below.
LOOP AT itab INTO totwa.
SUM.
ENDLOOP.
totwa is defined as a workarea which is needed to hold the sum totals of the fields in the itab. According to the documentation of SUM, it should calculate the sum totals and should put the totals in the workarea mentioned. But somehow its not calculating the value. Could anyone please help me in resolving this issue. Please guide me with your thoughts as to what might have gone wrong.
Note: the itab fields are of type P.
Thanks in advance
Sudha NaikHello Suha
According to the ABAP documentation the SUM statement is used in a specific situation:
<b>Syntax
SUM. </b>
<b>Effect </b>
<i>The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT-ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables. </i>
<i>The statement SUM calculates the component total with the numeric data type ( i, p, f) of all rows in the current control level and assigns these to the components of the work area wa. In the control levels FIRST, LAST , and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table.</i>
I hope the following sample report will clarify the use of <b>SUM </b>and <b>COLLECT</b>.
*& Report ZUS_SDN_COLLECT
REPORT zus_sdn_collect.
TYPES: BEGIN OF ty_s_line.
TYPES: key(1) TYPE n.
TYPES: value TYPE p DECIMALS 2.
TYPES: END OF ty_s_line.
TYPES: ty_t_itab TYPE STANDARD TABLE OF ty_s_line
WITH DEFAULT KEY.
DATA:
gs_line TYPE ty_s_line,
gt_itab TYPE ty_t_itab,
gt_itab_coll TYPE ty_t_itab.
START-OF-SELECTION.
DO 3 TIMES.
gs_line-key = syst-index.
gs_line-value = syst-index * '2.3'.
APPEND gs_line TO gt_itab.
APPEND gs_line TO gt_itab.
ENDDO.
gs_line-key = 4.
gs_line-value = '5.5'.
APPEND gs_line TO gt_itab.
WRITE: / 'Initial list'.
LOOP AT gt_itab INTO gs_line.
WRITE: / gs_line-key,
gs_line-value.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
WRITE: / 'Using SUM statement with AT END OF'.
SORT gt_itab BY key.
LOOP AT gt_itab INTO gs_line.
AT END OF key.
SUM.
WRITE: / gs_line-key,
gs_line-value.
ENDAT.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
WRITE: / 'Using SUM statement without control structure (1)'.
SORT gt_itab BY key.
LOOP AT gt_itab INTO gs_line.
SUM.
WRITE: / gs_line-key,
gs_line-value.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
WRITE: / 'Using SUM statement without control structure (2)'.
SORT gt_itab BY key.
LOOP AT gt_itab INTO gs_line.
SUM.
WRITE: / gs_line-key,
gs_line-value.
EXIT.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
WRITE: / 'Using COLLECT statement'.
REFRESH: gt_itab_coll.
LOOP AT gt_itab INTO gs_line.
COLLECT gs_line INTO gt_itab_coll.
ENDLOOP.
LOOP AT gt_itab_coll INTO gs_line.
WRITE: / gs_line-key,
gs_line-value.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
WRITE: / 'Using COLLECT statement for total sum'.
REFRESH: gt_itab_coll.
LOOP AT gt_itab INTO gs_line.
gs_line-key = 0.
COLLECT gs_line INTO gt_itab_coll.
ENDLOOP.
LOOP AT gt_itab_coll INTO gs_line.
WRITE: / gs_line-key,
gs_line-value.
ENDLOOP.
WRITE: / syst-uline.
SKIP 2.
END-OF-SELECTION.
Regards
Uwe -
Export statement in user-exit??
I have used the following export statement in a user-exit:"EXPORT xaccit TO MEMORY ID 'ZCACHEPPA'."-I have doubt that - will this statement export the contents of the table XACCIT to memory and those contents in the memory will be imported by the IMPORT statement in other user-exit.....??
If no,then which EXPORT/IMPORT statement should be used....is there any other keyword that can be used to export the contents to the memory?Hi
See the doc related to SAP Memory and ABAP memory
SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens
SAP global memory retains field value through out session.
set parameter id 'MAT' field v_matnr.
get parameter id 'MAT' field v_matnr.
They are stored in table TPARA.
ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data
to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.
ABAP memory is temporary and values are retained in same LUW.
export itab to memory id 'TEST'.
import itab from memory Id 'TEST'.
Here itab should be declared of same type and length.
http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
ABAP Memmory & SAP Memmory
http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Reward points if useful
Regards
Anji -
How to download data from itab to Excel sheet..
Hi sap Experts,
I develop one report to download data from itab to excel sheet.I done it perfectly.
My doubt is in the excel sheet i need to put headings. and also at last i need to display total no.of Records.
Please help me how to do this.
Thanks in Advance....
Thanks and Regards
Siri.......................u can either use GUI_DOWNLOAD or the method below...just give a try
DATA:WK_string TYPE STRING.
DATA:Wk_EXT(4) TYPE C value '.xls'.
DATA:WK_path TYPE STRING.
DATA:wk_file_name type string.
data:wk_records type sy-tfill.
wk_file_name = 'Downloaded'.
describe table itab lines wk_records.
LOOP AT ITAB.
at first.
**Provide path
concatenate 'C:\' wk_file_name Wk_EXT into wk_path.
open dataset WK_path for output in text mode encoding default.
if sy-subrc 0.
write:'ERROR while opening dataset !!!!!!'.
EXIT.
endif.
CONDENSE wk_path.
**Heading Part
concatenate 'Part No' 'Description'
into wk_string separated by cl_abap_char_utilities=>horizontal_tab.
endat.
**Data ITAB
CONCATENATE ITAB-MATNR itab-maktx into wk_string
separated by cl_abap_char_utilities=>horizontal_tab.
transfer wk_string to WK_path.
at last.
clear wk_string.
Concatenate 'Records Passed:' wk_string into wk_string.
transfer wk_string to WK_path.
close dataset WK_path.
endat.
endloop. -
Badi or user exit for FTR_CREATE for modifying the Payment Details
Hi,
I need a Badi or user exit that will modify the internal table for the "Payment Details" in transaction FTR_CREATE. Basically, instead of using the default entries in the "Payment Details", data from a Z custom table will overwrite the "Payment details" or the internal table containing the "Payment details". This should create entries in the Transparent Table VTBZV with the values fron the Z custom table.
I'm trying to implement the BADI FTR_TR_GENERIC but I cannot find where and how to modify the original "Payment Details" entries. Or if its even possible to do this.Hi Ravi,
I was trying to do that but I am not sure were to start. I tried to modify the contents of PI_PROXY_TRANSACTION->A_TAB_CASHFLOW using MODIFY <itab> but an error occured when I tried to activate it saying that the Class/Interdace Attribute is read-only and cannot be modified. Is there a Method that I need to do in order to modify the Attribute? (I'm not that familiar yet with Classes and Methods though)
Also, just to test, I manually changed the contents of two internal tables containing the "Payment Details" data during debug mode. But after the program has ended its run and finally saved the data, the Table VTBZV was not updated with the manual data I introduced. So I'm not sure if the Badi FTR_TR_GENERIC (which is I'm implementing) really allows the "Payment Details" to be modified or if I'm modifying the correct internal table(s).
Maybe you are looking for
-
Unable to Change Project Start Date in Project Server 2013
Dear All, I have created new EPT in Project Server 2013. After that, when i am creating any new project in PWA 2013 by using newly created EPT, then i am not able to change Date as per my requirement. Basically, EPT created on 02/18/2015 & even thou
-
Color corection not showing up in output
I am a bit of a newbie on this one but I am adding a bit of contrast and reducing brightness. Show up great in Premiere, just like I like it but after output, it looks jus tlike the original. What am i doing wrong. The original was shot at HD on a Ca
-
Hello all. I have been trying to open an access 2010 database and enter some data. I am able to open the database and even list the tables, there is only one, using the script (http://blogs.technet.com/b/heyscriptingguy/archive/2009/02/18/how-can-i-
-
Satellite L300D148 slow under Windows XP
Hi, I bought the Satellite L 300D and downgraded it to Windows XP Home SP3. I implemented the SATA driver with nLite (for AHCI) and everything went fine. The installation was trouble-free and I installed every driver from the europe toshiba site. How
-
How could I know the kind of an object in runtime ???
Hi, Is there any way in order that I can to know the kind of a control (xfa object) in runtime (using JavaScript)?. What's the attribute for that? For example: Drop-Down List : choiceList Text-Field : textEdit Check or Radio-Button : checkButton Than