Move to first record of ref curser after fetch
I have the following package (v2 is not used in this example):
CREATE OR REPLACE PACKAGE test_ref_cursor AS
TYPE gc IS REF CURSOR;
PROCEDURE test_ref_cursor(v1 OUT gc
,v2 IN VARCHAR2
,v3 OUT VARCHAR2);
END;
CREATE OR REPLACE PACKAGE BODY test_ref_cursor AS
PROCEDURE test_ref_cursor(v1 OUT gc
,v2 IN VARCHAR2
,v3 OUT VARCHAR2) AS
r1 scott.emp%ROWTYPE;
BEGIN
OPEN v1 FOR
SELECT * FROM scott.emp;
FETCH v1 INTO r1;
IF v1%NOTFOUND
THEN
v3 := 'not found';
ELSE
v3 := 'found';
END IF;
END;
END;
The calling procedure below tests whether the cursor contains data. If so, it fetches the data and displays it. However, the first row does not get fetched anymore (notice that SMITH is missing and rowcount begins at 2) because the procedure in the package already fetched it. How can i begin fetching at row one of the cursor again?
1 DECLARE
2 TYPE rc IS REF CURSOR;
3 c rc;
4 r scott.emp%ROWTYPE;
5 e varchar2(10);
6 BEGIN
7 test_ref_cursor.test_ref_cursor(v1 => c
8 ,v2 => 'MILLER'
9 ,v3 => e);
10 IF e = 'found'
11 THEN
12 LOOP
13 FETCH c INTO r;
14 EXIT WHEN c%NOTFOUND;
15 dbms_output.put_line(c%ROWCOUNT || ': ' || r.ename);
16 END LOOP;
17 END IF;
18* END;
19 /
2: ALLEN
3: WARD
4: JONES
5: MARTIN
6: BLAKE
7: CLARK
8: SCOTT
9: KING
10: TURNER
11: ADAMS
12: JAMES
13: FORD
14: MILLER
PL/SQL procedure successfully completed.
Thank you,
christoph
I will leave the interpretation of the results from
the following test runs as an exercise to you.
SQL> set serveroutput on
SQL> DECLARE
2 v1 sys_refcursor;
3 v3 VARCHAR2(10);
4 BEGIN
5 OPEN v1 FOR
6 SELECT * FROM scott.emp;
7 IF v1%NOTFOUND
8 THEN
9 v3 := 'not found';
10 ELSE
11 v3 := 'found';
12 END IF;
13 CLOSE v1;
14 dbms_output.put_line('v3=' || v3);
15 END;
16 /
v3=found
PL/SQL procedure successfully completed.
SQL> DECLARE
2 v1 sys_refcursor;
3 v3 VARCHAR2(10);
4 BEGIN
5 OPEN v1 FOR
6 SELECT * FROM scott.emp WHERE 1 = 2;
7 IF v1%NOTFOUND
8 THEN
9 v3 := 'not found';
10 ELSE
11 v3 := 'found';
12 END IF;
13 CLOSE v1;
14 dbms_output.put_line('v3=' || v3);
15 END;
16 /
v3=found
PL/SQL procedure successfully completed.
SQL> DECLARE
2 v1 sys_refcursor;
3 v3 VARCHAR2(10);
4 rec scott.emp%ROWTYPE;
5 BEGIN
6 OPEN v1 FOR
7 SELECT * FROM scott.emp WHERE 1 = 2;
8 FETCH v1
9 INTO rec;
10 IF v1%NOTFOUND
11 THEN
12 v3 := 'not found';
13 ELSE
14 v3 := 'found';
15 END IF;
16 CLOSE v1;
17 dbms_output.put_line('v3=' || v3);
18 END;
19 /
v3=not found
PL/SQL procedure successfully completed.
SQL>
How about this:
SQL> DECLARE
2 v1 sys_refcursor;
3 v3 VARCHAR2(10);
4 rec bbhatta.emp%rowtype;
5 BEGIN
6 OPEN v1 FOR SELECT * FROM bbhatta.emp WHERE 1 = 2;
7 IF v1%NOTFOUND
8 THEN
9 v3 := 'not found';
10 ELSE
11 v3 := 'found';
12 END IF;
13 FETCH v1
14 INTO rec;
15 CLOSE v1;
16 dbms_output.put_line('v3=' || v3);
17 END;
18 /
v3=found
PL/SQL procedure successfully completed.
Similar Messages
-
Internal table - move record to first record in table
How can a move a record already in an internal table to the first record in the table? There is no appropriate sort that would make it the first record.
Assuming the record is in the header:
delete itab.
insert itab index 1.
That should be - assuming sy-index already points to the record you want to move.
Rob
Message was edited by: Rob Burbank -
Can I move cursor to first record without reopen it?
I want to use the same cursor in my stored procedure
for many times, but it is time expensive to open this
cursor. So can I move the cursor to the first record
when it come to the last without close and reopen this
cursor?You could read your data at once into a collection and then process the collection afterwards as you like:
For an example see
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#28373 -
Invalid Descriptor Index After First Record
recordCount = 1;
if(rs != null)
rs.last();
totalRows = rs.getRow();
rs.first();
System.out.println("Total Rows: "+totalRows);
if (rs != null) while ( rs.next() )
hasResults = true;
for(rowCount = 0; rowCount < totalRows; rowCount++)
for(columnCount = 0; columnCount < 9; columnCount++)
SearchMenu.fieldArray[rowCount][columnCount].setText(rs.getString(recordCount));
recordCount++;
}I am using the above code to read and display data in a 20 row 9 column array of text fields. The database has 9 columns. The first record in a query is displaying correctly, but then I get Invalid Descriptor Index (and no more records are displayed). Can anyone help? Thanks a bunch.I went ahead and tried resetting the recordCount to 1
after each row like you suggested, but that produced
the same error and problem. Then you have another problem. But I doubt this is happening.
It is my understanding
that the first object in the resultset's second row
is one past the last object of the first row, so
resetting this count doesn't make sense to me
anyway.I don't know what you mean exactly but I am pretty sure this is wrong.
Try this.
recordCount = 1;
if(rs != null)
rs.last();
totalRows = rs.getRow();
rs.first();
System.out.println("Total Rows: "+totalRows);
if (rs != null) while ( rs.next() )
hasResults = true;
recordCount = 1;//new line here!
for(rowCount = 0; rowCount < totalRows; rowCount++)
for(columnCount = 0; columnCount < 9; columnCount++)
SearchMenu.fieldArray[rowCount][columnCount].setText(rs.getString(recordCount));
recordCount++;
} -
The first few movies I rented began to play shortly after the download started, but the one I'm renting today will not let me play during the download. Why?
Does anything here help: http://support.apple.com/kb/TS1389?viewlocale=en_US
-
How to skip first record while inserting data from a flat file to BW system
Hi Experts,
In my project we have to upload flat file into a BW system. I have written a program and it is working fine.
Now we have got another requirement. The flat file will have a header record (first row). While uploading the flat file we have to skip this record. How I can do so?
The code is as below:
FORM upload1.
DATA : wf_title TYPE string,
lt_filetab TYPE filetable,
l_separator TYPE char01,
l_action TYPE i,
l_count TYPE i,
ls_filetab TYPE file_table,
wf_delemt TYPE rollname,
wa_fieldcat TYPE lvc_s_fcat,
tb_fieldcat TYPE lvc_t_fcat,
rows_read TYPE i,
p_error TYPE char01,
l_file TYPE string.
DATA: wf_object(30) TYPE c,
wf_tablnm TYPE rsdchkview.
wf_object = 'myprogram'.
DATA i TYPE i.
DATA:
lr_mdmt TYPE REF TO cl_rsdmd_mdmt,
lr_mdmtr TYPE REF TO cl_rsdmd_mdmtr,
lt_idocstate TYPE rsarr_t_idocstate,
lv_subrc TYPE sysubrc.
TYPES : BEGIN OF test_struc,
/bic/myprogram TYPE /bic/oimyprogram,
txtmd TYPE rstxtmd,
END OF test_struc.
DATA : tb_assum TYPE TABLE OF /bic/pmyprogram.
DATA: wa_ztext TYPE /bic/tmyprogram,
myprogram_temp TYPE ziott_assum,
wa_myprogram TYPE /bic/pmyprogram.
DATA : test_upload TYPE STANDARD TABLE OF test_struc,
wa2 TYPE test_struc.
DATA : wa_test_upload TYPE test_struc,
ztable_data TYPE TABLE OF /bic/pmyprogram,
ztable_text TYPE TABLE OF /bic/tmyprogram,
wa_upld_text TYPE /bic/tmyprogram,
wa_upld_data TYPE /bic/pmyprogram,
t_assum TYPE ziott_assum.
DATA : wa1 LIKE test_upload.
wf_title = text-026.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = wf_title
default_extension = 'txt'
file_filter = 'Tab delimited Text Files (*.txt)'
CHANGING
file_table = lt_filetab
rc = l_count
user_action = l_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
OTHERS = 3. "#EC NOTEXT
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT lt_filetab INTO ls_filetab.
l_file = ls_filetab.
ENDLOOP.
CHECK l_action = 0.
IF l_file IS INITIAL.
EXIT.
ENDIF.
l_separator = 'X'.
wa_fieldcat-fieldname = 'test'.
wa_fieldcat-dd_roll = wf_delemt.
APPEND wa_fieldcat TO tb_fieldcat.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
CLEAR wa_test_upload.
Upload file from front-end (PC)
File format is tab-delimited ASCII
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
has_field_separator = l_separator
TABLES
data_tab = i_mara
data_tab = test_upload
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.
EXIT.
ELSE.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
IF test_upload IS NOT INITIAL.
DESCRIBE TABLE test_upload LINES rows_read.
CLEAR : wa_test_upload,wa_upld_data.
LOOP AT test_upload INTO wa_test_upload.
CLEAR : p_error.
rows_read = sy-tabix.
IF wa_test_upload-/bic/myprogram IS INITIAL.
p_error = 'X'.
MESSAGE s153 WITH wa_test_upload-/bic/myprogram sy-tabix.
CONTINUE.
ELSE.
TRANSLATE wa_test_upload-/bic/myprogram TO UPPER CASE.
wa_upld_text-txtmd = wa_test_upload-txtmd.
wa_upld_text-txtsh = wa_test_upload-txtmd.
wa_upld_text-langu = sy-langu.
wa_upld_data-chrt_accts = 'xyz1'.
wa_upld_data-co_area = '12'.
wa_upld_data-/bic/zxyzbcsg = 'Iy'.
wa_upld_data-objvers = 'A'.
wa_upld_data-changed = 'I'.
wa_upld_data-/bic/zass_mdl = 'rrr'.
wa_upld_data-/bic/zass_typ = 'I'.
wa_upld_data-/bic/zdriver = 'yyy'.
wa_upld_text-langu = sy-langu.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
APPEND wa_upld_data TO ztable_data.
APPEND wa_upld_text TO ztable_text.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ztable_data.
DELETE ADJACENT DUPLICATES FROM ztable_text.
IF ztable_data IS NOT INITIAL.
CALL METHOD cl_rsdmd_mdmt=>factory
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_r_mdmt = lr_mdmt
EXCEPTIONS
invalid_iobjnm = 1
OTHERS = 2.
CALL FUNCTION 'MESSAGES_INITIALIZE'.
**Lock the Infoobject to update
CALL FUNCTION 'RSDG_IOBJ_ENQUEUE'
EXPORTING
i_objnm = wf_object
i_scope = '1'
i_msgty = rs_c_error
EXCEPTIONS
foreign_lock = 1
sys_failure = 2.
IF sy-subrc = 1.
MESSAGE i107(zddd_rr) WITH wf_object sy-msgv2.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE i108(zddd_rr) WITH wf_object.
EXIT.
ENDIF.
*****Update Master Table
IF ztable_data IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'M'
I_T_ATTR = lt_attr
TABLES
i_t_table = ztable_data
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '054'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
MESSAGE e054(zddd_rr) WITH 'myprogram'.
ELSE.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'S'
txtnr = '053'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
*endif.
*****update Text Table
IF ztable_text IS NOT INITIAL.
CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
EXPORTING
i_iobjnm = 'myprogram'
i_tabclass = 'T'
TABLES
i_t_table = ztable_text
EXCEPTIONS
attribute_name_error = 1
iobj_not_found = 2
generate_program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'MESSAGE_STORE'
EXPORTING
arbgb = 'zddd_rr'
msgty = 'E'
txtnr = '055'
msgv1 = text-033
EXCEPTIONS
OTHERS = 3.
ENDIF.
ENDIF.
ELSE.
MESSAGE s178(zddd_rr).
ENDIF.
ENDIF.
COMMIT WORK.
CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS'
EXPORTING
i_chabasnm = 'myprogram'
IMPORTING
e_chktab = wf_tablnm
EXCEPTIONS
name_error = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
****Release locks on Infoobject
CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
EXPORTING
i_objnm = 'myprogram'
i_scope = '1'.
ENDIF.
ENDIF.
PERFORM data_selection .
PERFORM update_alv_grid_display.
CALL FUNCTION 'MESSAGES_SHOW'.
ENDFORM.
Please let me know how I can skip first record of the flat file?
Regards,
Sgo through this hope u can get some idea
REPORT ztest no standard page heading line-size 255.
Declaration *
TYPES t_itab1 TYPE alsmex_tabline.
types: begin of t_csks,
kostl like csks-kostl,
end of t_csks.
types: begin of t_cska,
kstar like cska-kstar,
end of t_cska.
data: begin of t_flatfile,
docdate like COHEADER-BLDAT,
postdate like COHEADER-BUDAT,
doctext like COHEADER-BLTXT,
costele like RK23F-KSTAR,
amount like RK23F-WTGBTR,
scostctr like RK23F-SKOSTL,
rcostctr like RK23F-EKOSTL,
rintorder like RK23F-EAUFNR,
end of t_flatfile.
data: begin of t_flatfile1,
docdate like COHEADER-BLDAT,
postdate like COHEADER-BUDAT,
doctext like COHEADER-BLTXT,
costele like RK23F-KSTAR,
amount like RK23F-WTGBTR,
scostctr like RK23F-SKOSTL,
rcostctr like RK23F-EKOSTL,
rintorder like RK23F-EAUFNR,
NUM LIKE SY-INDEX,
end of t_flatfile1.
data: itab like table of t_flatfile with header line.
data: itab2 like table of t_flatfile1 with header line.
DATA: it_itab1 TYPE STANDARD TABLE OF t_itab1 WITH HEADER LINE,
MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data:t_lin type i VALUE '0',
u_rec type i VALUE '0',
s_rec type i VALUE '0'.
data: it_csks type standard table of t_csks,
wa_csks type t_csks.
data: it_cska type standard table of t_cska,
wa_cska type t_cska.
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
parameters: p_docdat LIKE COHEADER-BLDAT obligatory,
p_postda LIKE COHEADER-BUDAT obligatory,
p_doctxt LIKE COHEADER-BLTXT.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-011.
parameters: p_file LIKE RLGRAP-FILENAME obligatory,
DIS_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK b2.
A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_local_file_name USING p_file.
*Start of Selection
START-OF-SELECTION.
Perform get_Excel_data.
perform validate_data.
Perform Process_Data.
end-of-selection
end-of-selection.
perform display_data.
*& Form get_local_file_name
text
-->P_P_FILE text
FORM get_local_file_name USING P_P_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = p_file.
ENDFORM. " get_local_file_name
*& Form get_Excel_data
text
--> p1 text
<-- p2 text
FORM get_Excel_data .
FIELD-SYMBOLS : <FS>.
DATA : V_INDEX TYPE I.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 2
i_begin_row = 1
i_end_col = 256
i_end_row = 9999 "65536
TABLES
intern = it_itab1
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.
Message text-013 type 'E'.
ENDIF.
IF IT_ITAB1[] IS INITIAL.
Message text-001 type 'E'.
else. "IF IT_ITAB1[] IS INITIAL.
data: itab2 like itab occurs 0 with header line.
SORT IT_ITAB1 BY ROW COL.
LOOP AT IT_ITAB1.
MOVE :IT_ITAB1-COL TO V_INDEX.
ASSIGN COMPONENT V_INDEX OF STRUCTURE itab2 TO <FS>.
MOVE : IT_ITAB1-VALUE TO <FS>.
AT END OF ROW.
MOVE-CORRESPONDING itab2 TO itab.
APPEND itab.
CLEAR:itab,itab2.
ENDAT.
endloop.
describe table itab lines t_lin.
endif. "IF IT_ITAB1[] IS INITIAL.
ENDFORM. " get_Excel_data
*& Form Process_Data
text
--> p1 text
<-- p2 text
FORM Process_Data .
data:l_tabix type sy-tabix.
data:l_periv like t001-periv,
l_monat like bkpf-monat,
l_gjahr like bkpf-gjahr,
l_amt(21) type c.
data: l_ddate(10),
l_pdate(10).
WRITE p_docdat TO l_ddate.
WRITE p_postda TO l_pdate.
clear: l_periv,l_monat,l_gjahr.
select single periv from t001 into l_periv where bukrs = '5000'. "P_bukrs
if sy-subrc eq 0.
l_gjahr = p_postda+0(4).
call function 'FI_PERIOD_DETERMINE'
EXPORTING
i_budat = p_postda
i_bukrs = '5000' "p_bukrs
i_periv = l_periv
i_gjahr = l_gjahr
IMPORTING
e_monat = l_monat.
clear:l_periv.
endif.
loop at itab2.
refresh:bdcdata.
clear:bdcdata.
l_tabix = sy-tabix.
perform bdc_dynpro using 'SAPLK23F1' '1200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'COHEADER-SEND_REC_REL'
'10SAP'.
perform bdc_field using 'RK23F-STATUS'
'S'.
perform bdc_field using 'COHEADER-BLDAT'
itab-docdate.
l_ddate.
perform bdc_field using 'COHEADER-BUDAT'
itab-postdate.
l_pdate.
perform bdc_field using 'COHEADER-PERIO'
l_monat. "'9'.
perform bdc_field using 'COHEADER-BLTXT'
itab-doctext.
p_doctxt.
perform bdc_field using 'RK23F-KSTAR'
itab2-costele.
WRITE itab2-amount TO l_amt.
l_amt = itab-amount.
condense l_amt no-gaps.
perform bdc_field using 'RK23F-WTGBTR'
l_amt.
itab-amount.
perform bdc_field using 'RK23F-WAERS'
'USD'.
*perform bdc_field using 'RK23F-SGTXT'
itab-doctext.
perform bdc_field using 'RK23F-SKOSTL'
itab2-scostctr.
perform bdc_field using 'BDC_CURSOR'
'RK23F-EAUFNR'.
perform bdc_field using 'RK23F-EKOSTL'
itab2-rcostctr.
perform bdc_field using 'RK23F-EAUFNR'
itab2-rintorder.
perform bdc_dynpro using 'SAPLK23F1' '1200'.
perform bdc_field using 'BDC_OKCODE'
'=POST'.
perform bdc_field using 'COHEADER-SEND_REC_REL'
'10SAP'.
perform bdc_field using 'RK23F-STATUS'
'S'.
perform bdc_field using 'COHEADER-BLDAT'
itab-docdate.
l_ddate.
perform bdc_field using 'COHEADER-BUDAT'
itab-postdate.
l_pdate.
perform bdc_field using 'COHEADER-PERIO'
'9'.
l_monat.
perform bdc_field using 'COHEADER-BLTXT'
itab-doctext.
p_doctxt.
perform bdc_field using 'BDC_CURSOR'
'RK23F-KSTAR'.
perform bdc_field using 'RK23F-WAERS'
'USD'.
CALL TRANSACTION 'KB15N' USING BDCDATA MODE DIS_MODE MESSAGES INTO MESSTAB.
If sy-subrc = 0.
s_rec = s_rec + 1.
ELSE.
u_rec = u_rec + 1.
move ITAB2-NUM to messtab1-msgv1.
concatenate itab2-costele ' | ' itab2-scostctr ' | ' itab2-rcostctr ' | ' itab2-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
endif.
clear:itab2.
endloop.
ENDFORM. " Process_Data
BDC_DYNPRO *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
BDC_FIELD *
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> ''. "NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. "BDC_FIELD
*& Form display_data
text
--> p1 text
<-- p2 text
FORM display_data .
skip 2.
write:/15 text-002.
skip 2.
write:/8 text-003.
SKIP.
write:/12 text-008,
25 P_DOCDAT.
SKIP.
write:/12 text-009,
25 P_POSTDA.
SKIP.
write:/12 text-012,
25 P_DOCTXT.
SKIP.
write:/12 text-004,
25 p_file.
skip 2.
write:/8 text-005,
60 t_lin.
skip.
write:/8 text-006,
60 s_rec.
skip.
write:/8 text-007,
60 u_rec.
skip.
write:/10 'row no',
20 'Information'.
skip.
loop at messtab1.
write:/10 messtab1-msgv1,
20 messtab1-msgv2.
clear:messtab1.
endloop.
ENDFORM. " display_data
*& Form validate_data
text
--> p1 text
<-- p2 text
FORM validate_data .
data: l_tabix1 type sy-tabix.
data: l_tabix2 type sy-tabix.
if not itab[] is initial.
select kostl from CSKS into table it_csks.
if sy-subrc eq 0.
sort it_csks by kostl.
endif.
select kstar from CSKA into table it_cska.
if sy-subrc eq 0.
sort it_cska by kstar.
endif.
loop at itab.
l_tabix1 = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-scostctr
IMPORTING
OUTPUT = itab-scostctr .
read table it_csks into wa_csks with key kostl = itab-scostctr.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
move itab-rintorder to messtab1-msgv2.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-rcostctr
IMPORTING
OUTPUT = itab-rcostctr .
read table it_csks into wa_csks with key kostl = itab-rcostctr.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab-costele
IMPORTING
OUTPUT = itab-costele .
read table it_cska into wa_cska with key kstar = itab-costele.
if sy-subrc ne 0.
u_rec = u_rec + 1.
L_TABIX2 = l_tabix1 + 1.
move l_tabix2 to messtab1-msgv1.
move l_tabix1 to messtab1-msgv1.
concatenate itab-costele ' | ' itab-scostctr ' | ' itab-rcostctr ' | ' itab-rintorder into messtab1-msgv2.
condense messtab1-msgv2.
condense messtab1-msgv1.
append messtab1.
clear:wa_csks.
CLEAR:L_TABIX2.
continue.
endif.
move-corresponding itab to itab2.
MOVE l_tabix1 TO ITAB2-NUM.
append itab2.
clear: itab2.
clear:itab.
endloop.
else.
message 'No records in File' type 'S'.
endif.
ENDFORM. " validate_data -
See my problem no master record move to next record
hi master
sir
i have master detail block master table have all data but detail no data i need feed data in detail then i goto in detail block write value and press F10 for save
for new record in detail
in detail blick post-block or post_record or post_insert event i write this code
go_block('masterblock');
next_record;
go_item('detailblock.item');
but not responses no master block move to next record still and my curser sitll in last postion
sir how i move master record after save the detail record and jump to detail block for new record
please give me idea or code
thanking you
aamirthank for reply
sir your help very usefull for my but when i press F10 then system show massage do you want to save change the record
sir how i avoid that window and directly move to next record
please give me idea
thanking you
aamir -
How to return to the first record of a multiple row cursor (Forms 6i)
Hi all,
I had a bit of a search through here, but couldn't quite find the answer I'm after.
I have a multiple row cursor, which I feed into a multi-row block in Forms 6i. I have the following code:
OPEN CURSOR;
LOOP
FETCH CURSOR INTO :FIELD1, :FIELD2, :FIELD3, :FIELD4;
... do other code not related with cursor
EXIT WHEN CURSOR%NOTFOUND;
NEXT_RECORD;
END LOOP;Now, I use the Forms built-in NEXT_RECORD to move down through the records on the form and fill in each row from the db. However, once the block loads (this works correctly), the current item (ie where the typing cursor is left) is on the last record.
Obviously, I need the current item (after loading) to be on the first record. I tried using the Forms built-in FIRST_RECORD after the END LOOP command, but that gives me an ORA-06511 error (An attempt was made to open a cursor that was already open).
Does anyone know how I might be able to return to the first record of the block correctly?
Thanks in Advance,
Chris.Ok, I feel like a bit of a dolt.
I found that all cursors had to be closed before navigating back to the first record.
Case closed! :) -
Hi,
Can anybody give me the code to move through the records (one after the other) in Module pool programing. Assuming that I have a pushbutton, whenever i click on that button (assume button labeled as Next) it should move to the next record and to be displayed in the input/output field.
Thanks,
Sriram.Hi Sriram
I think you aren't using a table control, are you?
You should use a index where you save the number of the index of record which is displayed.
DATA: INDEX_SHOW TYPE SY-TABIX.
I suppose that this index is 1 in the first time, after:
CASE OK_CODE.
WHEN 'NEXT'.
INDEX_SHOW = INDEX_SHOW + 1.
READ TABLE MY_TABLE INDEX INDEX-SHOW.
MOVE MY_TABLE TO <SCREEN FIELD>.
WHEN 'PREV'.
INDEX_SHOW = INDEX_SHOW - 1.
IF INDEX_SHOW = 0.
INDEX_SHOW = 1.
ENDIF.
READ TABLE MY_TABLE INDEX INDEX-SHOW.
MOVE MY_TABLE TO <SCREEN FIELD>.
You can use a index where you save the total number of records in your table:
DATA: INDEX_SHOW TYPE SY-TABIX,
TOT_REC TYPE SY-TABIX.
DESCRIBE TABLE MY_TABLE LINES TOT_REC.
I suppose that this index is 1 in the first time, after:
CASE OK_CODE.
WHEN 'NEXT'.
INDEX_SHOW = INDEX_SHOW + 1.
So now you can check if INDEX_SHOW isn't greater than
TOT_REC.
IF INDEX_SHOW > TOT_REC.
INDEX_SHOW = TOT_REC.
ENDIF.
READ TABLE MY_TABLE INDEX INDEX-SHOW.
MOVE MY_TABLE TO <SCREEN FIELD>.
WHEN 'PREV'.
INDEX_SHOW = INDEX_SHOW - 1.
IF INDEX_SHOW = 0.
INDEX_SHOW = 1.
ENDIF.
READ TABLE MY_TABLE INDEX INDEX-SHOW.
MOVE MY_TABLE TO <SCREEN FIELD>. -
Merge 2 internal tables into one and show first record from common fields
Hello PPl,
I have 3 tables kna1 knb1 and knvp i have to join kna1 and knb1 on kunnr and move the data into an internal table it_data then on the basis of that data in it_data i have to retrieve records FOR ALL ENTRIES from KNVP and move it into it_knvp.
Then both it_data and it_knvp should be merged in it_alv and from that internal table report has to be displayed.
[NOTE: i had tried using loop twice but the report got messed up]
Apart from that for these set of values
0000000004
0000000418
0000000954
0000001190
0000001222
0000001451
0000001453
0000001455
0000001470
0000001508
finally knvp is showing records in such a way that for 2 records kunnr is same and so does all the other fields except PARZA and KUNN2 so the req. is to display only the first record among 2.
Plz help me by providing code for that its urgent......
Below i m providing my code so far, i hope it will be of some help.
TREMENDOUS REWARD POINTS GURANTEED!!!!!
REPORT zfanz_alv_report_whv.
TYPE-GROUPS *
TYPE-POOLS: slis.
TYPES *
TYPES: BEGIN OF ty_data,
kunnr TYPE kunnr,
ort01 TYPE ort01,
pstlz TYPE pstlz,
regio TYPE regio,
bukrs TYPE bukrs,
zterm TYPE zterm,
END OF ty_data,
BEGIN OF ty_knvp,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
parvw TYPE parvw,
parza TYPE parza,
kunn2 TYPE kunn2,
lifnr TYPE lifnr,
END OF ty_knvp,
BEGIN OF ty_alv,
kunnr TYPE kunnr,
ort01 TYPE ort01,
pstlz TYPE pstlz,
regio TYPE regio,
bukrs TYPE bukrs,
zterm TYPE zterm,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
spart TYPE spart,
parvw TYPE parvw,
parza TYPE parza,
kunn2 TYPE kunn2,
lifnr TYPE lifnr,
END OF ty_alv,
BEGIN OF ty_kna1,
kunnr TYPE kunnr,
END OF ty_kna1,
BEGIN OF ty_knb1,
bukrs TYPE bukrs,
END OF ty_knb1.
*DATA: IT_KNVP TYPE KNVP,
DATA: it_knvp TYPE STANDARD TABLE OF ty_knvp WITH HEADER LINE.
DATA: it_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
Report data to be shown.
DATA: it_alv TYPE STANDARD TABLE OF ty_alv WITH HEADER LINE.
Heading of the report.
DATA: t_heading TYPE slis_t_listheader.
*DATA: fieldcatalog type standard table of slis_fieldcat_alv with header
*line.
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*TABLES
tables:knvp,kna1,knb1.
CONSTANTS *
CONSTANTS: c_kunnr TYPE char5 VALUE 'KUNNR',
c_ort01 TYPE char5 VALUE 'ORT01',
c_pstlz TYPE char5 VALUE 'PSTLZ',
c_regio TYPE char5 VALUE 'REGIO',
c_bukrs TYPE char5 VALUE 'BUKRS',
c_zterm TYPE char5 VALUE 'ZTERM',
c_vkorg TYPE char5 VALUE 'VKORG',
c_vtweg TYPE char5 VALUE 'VTWEG',
c_spart TYPE char5 VALUE 'SPART',
c_parvw TYPE char5 VALUE 'PARVW',
c_parza TYPE char5 VALUE 'PARZA',
c_kunn2 TYPE char5 VALUE 'KUNN2',
c_lifnr TYPE char5 VALUE 'LIFNR'.
WORKAREA *
DATA: wa_data TYPE ty_data,
wa_knvp TYPE ty_knvp,
wa_alv TYPE ty_alv,
wa_fcat TYPE slis_fieldcat_alv,
wa_layout TYPE slis_layout_alv.
======================= Selection Screen ==========================
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*DATA: wa_kunnr LIKE kna1-kunnr,
wa_bukrs LIKE knb1-bukrs,
wa_vkorg LIKE knvp-vkorg,
wa_vtweg LIKE knvp-vtweg,
wa_spart LIKE knvp-spart,
wa_parvw LIKE knvp-parvw.
SELECT-OPTIONS *
SELECT-OPTIONS s_kunnr FOR kna1-kunnr NO INTERVALS OBLIGATORY
SELECT-OPTIONS: s_bukrs FOR knb1-bukrs NO-EXTENSION NO INTERVALS,
s_vkorg FOR knvp-vkorg NO-EXTENSION NO INTERVALS,
s_vtweg FOR knvp-vtweg NO-EXTENSION NO INTERVALS,
s_spart FOR knvp-spart NO-EXTENSION NO INTERVALS,
s_parvw FOR knvp-parvw NO-EXTENSION NO INTERVALS.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN *
AT SELECTION-SCREEN ON s_kunnr.
PERFORM validate_data.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM get_data. "fetch data from table and perform join on them
PERFORM final_table.
PERFORM build_fieldcatalog. "populate field catalog
PERFORM build_layout.
PERFORM grid_display. "display the result in ALV grid
END-OF-SELECTION *
END-OF-SELECTION.
describe
SUBROUTINES (FORMS)
*& Form get_data
Gets the information to be shown in the report.
Join on tables KNA1, KNB1 and for all enteries in KNVP
--> p1 text
<-- p2 text
FORM get_data.
SELECT kna1~kunnr
kna1~ort01
kna1~pstlz
kna1~regio
knb1~bukrs
knb1~zterm
INTO TABLE it_data
FROM kna1 INNER JOIN knb1
ON kna1kunnr = knb1kunnr
WHERE kna1~kunnr IN s_kunnr
AND knb1~bukrs IN s_bukrs.
SELECT vkorg
vtweg
spart
parvw
parza
kunn2
lifnr
INTO TABLE it_knvp FROM knvp
FOR ALL ENTRIES IN it_data
WHERE knvp~kunnr = it_data-kunnr
AND vkorg IN s_vkorg
AND vtweg IN s_vtweg
AND spart IN s_spart
AND parvw IN s_parvw.
ENDFORM. " get_data
*ENDFORM. " get_data
*& Form FINAL_TABLE
text
--> p1 text
<-- p2 text
FORM final_table .
LOOP AT it_data.
it_alv-kunnr = it_data-kunnr.
it_alv-ort01 = it_data-ort01.
it_alv-pstlz = it_data-pstlz.
it_alv-regio = it_data-regio.
it_alv-bukrs = it_data-bukrs.
it_alv-zterm = it_data-zterm.
APPEND it_alv.
CLEAR it_alv.
ENDLOOP.
LOOP AT it_knvp.
it_alv-vkorg = it_knvp-vkorg.
it_alv-vtweg = it_knvp-vtweg.
it_alv-spart = it_knvp-spart.
it_alv-parvw = it_knvp-parvw.
it_alv-parza = it_knvp-parza.
it_alv-kunn2 = it_knvp-kunn2.
it_alv-lifnr = it_knvp-lifnr.
APPEND it_alv.
CLEAR it_alv.
ENDLOOP.
ENDFORM. " FINAL_TABLE
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
IF it_alv[] IS NOT INITIAL.
wa_fcat-fieldname = c_kunnr.
wa_fcat-seltext_l = 'Customer Master'(001).
wa_fcat-col_pos = 1.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_ort01.
wa_fcat-seltext_l = 'City'(002).
wa_fcat-col_pos = 2.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_pstlz.
wa_fcat-seltext_l = 'Postal Code'(003).
wa_fcat-col_pos = 3.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_regio.
wa_fcat-seltext_l = 'Region'(004).
wa_fcat-col_pos = 4.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_bukrs.
wa_fcat-seltext_l = 'Company Code'(005).
wa_fcat-col_pos = 5.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_zterm.
wa_fcat-seltext_l = 'Terms of payment'(006).
wa_fcat-col_pos = 6.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_vkorg.
wa_fcat-seltext_l = 'Sales Organization'(007).
wa_fcat-col_pos = 7.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_vtweg.
wa_fcat-seltext_l = 'Distribution Channel'(008).
wa_fcat-col_pos = 8.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_spart.
wa_fcat-seltext_l = 'Division'(009).
wa_fcat-col_pos = 9.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_parvw.
wa_fcat-seltext_l = 'Partner function'(010).
wa_fcat-col_pos = 10.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_kunn2.
wa_fcat-seltext_l = 'Customer number of partner'(011).
wa_fcat-col_pos = 11.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_lifnr.
wa_fcat-seltext_l = 'Account Number of Vendor'(012).
wa_fcat-col_pos = 12.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
wa_fcat-fieldname = c_parza.
wa_fcat-seltext_l = 'Partner counter'(013).
wa_fcat-col_pos = 13.
APPEND wa_fcat TO fieldcatalog.
CLEAR wa_fcat.
*fieldcatalog-fieldname = c_kunnr.
fieldcatalog-seltext_l = 'Customer Master'(001).
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_ort01.
fieldcatalog-seltext_l = 'City'(002).
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_pstlz.
fieldcatalog-seltext_l = 'Postal Code'(003).
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_regio.
fieldcatalog-seltext_l = 'Region'(004).
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_bukrs.
fieldcatalog-seltext_l = 'Company Code'(005).
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_zterm.
fieldcatalog-seltext_l = 'Terms of payment'(006).
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_vkorg.
fieldcatalog-seltext_l = 'Sales Organization'(007).
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_vtweg.
fieldcatalog-seltext_l = 'Distribution Channel'(008).
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_spart.
fieldcatalog-seltext_l = 'Division'(009).
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_parvw.
fieldcatalog-seltext_l = 'Partner function'(010).
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_kunn2.
fieldcatalog-seltext_l = 'Customer number of partner'(011).
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_lifnr.
fieldcatalog-seltext_l = 'Account Number of Vendor'(012).
fieldcatalog-col_pos = 12.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = c_parza.
fieldcatalog-seltext_l = 'Partner counter'(013).
fieldcatalog-col_pos = 13.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDIF.
ENDFORM. " BUILD_FIELDCATALOG
*& Form build_layout
text
--> p1 text
<-- p2 text
form build_layout .
Set layout field for field attributes(i.e. input/output)
wa_layout-stylefname = 'FIELD_STYLE'.
wa_layout-zebra = 'X'.
endform. " build_layout
*& Form GRID_DISPLAY
text
FORM grid_display. "using t_data type ty_tbl_data.
IF it_alv[] IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
IS_LAYOUT = wa_layout
it_fieldcat = fieldcatalog[]
TABLES
t_outtab = it_alv[]
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.
ENDIF.
ENDFORM. "GRID_DISPLAY
*& Form VALIDATE_DATA
text
--> p1 text
<-- p2 text
FORM validate_data .
DATA : li_kna1 TYPE STANDARD TABLE OF ty_kna1,
li_knb1 TYPE STANDARD TABLE OF ty_knb1,
li_knvp TYPE STANDARD TABLE OF ty_knvp.
SELECT kunnr
FROM kna1
INTO TABLE li_kna1
WHERE kunnr IN s_kunnr.
IF sy-subrc <> 0.
MESSAGE 'Invalid Customer Number'(013) TYPE 'E'.
ENDIF.
SELECT bukrs
FROM t001
INTO TABLE li_knb1
WHERE bukrs IN s_bukrs.
IF sy-subrc <> 0.
MESSAGE 'Invalid Company Code'(014) TYPE 'E'.
ENDIF.
SELECT vkorg
FROM tvko
INTO TABLE li_knvp
WHERE vkorg IN s_vkorg.
IF sy-subrc <> 0.
MESSAGE 'Invalid Sales Organization'(015) TYPE 'E'.
ENDIF.
SELECT vtweg
FROM tvtw
INTO TABLE li_knvp
WHERE vtweg IN s_vtweg.
IF sy-subrc <> 0.
MESSAGE 'Invalid Distribution Channel'(016) TYPE 'E'.
ENDIF.
SELECT spart
FROM tspa
INTO TABLE li_knvp
WHERE spart IN s_spart.
IF sy-subrc <> 0.
MESSAGE 'Invalid Division'(017) TYPE 'E'.
ENDIF.
SELECT parvw
FROM tpar
INTO TABLE li_knvp
WHERE parvw IN s_parvw.
IF sy-subrc <> 0.
MESSAGE 'Invalid Partner function'(018) TYPE 'E'.
ENDIF.
ENDFORM. " VALIDATE_DATA*1----
FORM get_data.
SELECT kna1~kunnr
kna1~ort01
kna1~pstlz
kna1~regio
knb1~bukrs
knb1~zterm
INTO TABLE it_data
FROM kna1 INNER JOIN knb1
ON kna1kunnr = knb1kunnr
WHERE kna1~kunnr IN s_kunnr
AND knb1~bukrs IN s_bukrs.
CHECK it_data[] IS NOT INITIAL.
SELECT kunnr
vkorg
vtweg
spart
parvw
parza
kunn2
lifnr
INTO TABLE it_knvp FROM knvp
FOR ALL ENTRIES IN it_data
WHERE kunnr = it_data-kunnr
AND vkorg IN s_vkorg
AND vtweg IN s_vtweg
AND spart IN s_spart
AND parvw IN s_parvw.
IF sy-subrc EQ 0.
SORT it_knvp BY kunnr.
ENDIF.
ENDFORM. " get_data
*2----
FORM final_table .
LOOP AT it_data INTO wa_data.
READ TABLE it_knvp
INTO wa_knvp
WITH KEY kunnr = wa_data-kunnr
BINARY SEARCH .
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_data TO wa_alv.
MOVE-CORRESPONDING wa_knvp TO wa_alv.
APPEND wa_alv TO it_alv.
ENDIF.
ENDLOOP.
ENDFORM. " FINAL_TABLE
Edited by: Faisal Khan on Mar 27, 2008 1:59 PM -
ResultSet loop back to first record
I have an Access table : products
I have a total of 7 products. When I use rs.next(), it will scroll for each record until the last record.
How do I make it go back to the first record after it hit the last record ?
I hv tried rs.first() and rs.last(0 method, but it doesn't work and give me TYPE FORWARD kind of error, further clarify with some expert, they said it is because my cursor state is the Forward Type only ... so cannot loop back....
Then I also use the cn.createConnection(ResultSet.InSensitive Result ... kind of stuff ... all cannot work as Access seems like cannot go backward ...
Any other good suggestion ?1. Use this, st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Or,
2. Store your result set in a temporary array and scroll thru this array for subsequent repetitive iterations.
Sudha -
File adapter SyncRead Operation adds "???" to first record of csv file
Hi All,
One interface is reading one CSV file (containing two fields only) using SyncRead Operation of File Adapter. But I found, when file adapter parsed the data it appends "???" to first field of the first record which cause further data validation in the process.
Test.csv file
123456,159357
147258,987654
Trace of the FileAdapter:
<messages>
<Invoke_FILE_Inbound_InputVariable>
<part name="Empty">
<empty/>
</part>
</Invoke_FILE_Inbound_InputVariable>
<Invoke_FILE_Inbound_OutputVariable>
<part name="body">
<Root-Element>
<TestElements>
<Emplid>���123456</Emplid>
<SupId>159357</SupId>
</TestElements>
<HRRespIDElements>
<Emplid>147258</Emplid>
<SupId>987654</SupId>
</TestElements>
</Root-Element>
</part>
</Invoke_FILE_Inbound_OutputVariable>
</messages>
Can anyone help me to understand , what is reason? Or I missed anything.
Thanks & Regards,
SharmisthaUnfortunately, this is documented bahaviour (solution/workaround anyone?!):
Elapsed Time Exceeds:
Specify a time which, when exceeded, causes a new outgoing file to be created.
Note:
The Elapsed Time Exceeds batching criteria is evaluated and a new outgoing file is created, only when an invocation happens.
For example, if you specify that elapsed time exceeds 15 seconds, then the first message that is received is not written out, even after 15 seconds, as batching conditions are not valid. If a second message is received, then batching conditions become valid for the first one, and an output file is created when the elapsed time exceeds 15 seconds. -
Data Loader - Only imports first record; remaining records fail
I'm trying to use Data Loader to import a group of opportunities. Everytime I run the Data Loader it only imports the first record. All the other records fail with the message "An unexpected error occurred during the import of the following row: 'External Unique Id: xxxxxxx'". After running the Data Loader, I can modify the Data file and remove the first record that was imported. By running the Data Loader again, the first row (previously the second row) will import successfully.
Any idea what could be causing this behavior?W need a LOT more information, starting with the OS, and the version of ID, including any applied patches.
Next we need to know if you are doing a single record per page or multiple records, whether the placeholders are on the master page, how many pages are in the document and if they all have fields on them (some screen captures might be useful -- embed them using the camera icon on the editing toolbar on the webpage rather than attaching, if it works [there seem to be some issues at the moment, though only for some people]).
What else is on the page? Are you really telling it to merge all the records, or just one?
You get the idea... Full description of what youhave, what you are doing, and what you get instead of what you expect. -
Next,previous,last, and first record
dear all masters
plz help me my code dont work
i used button when button pressed and code below
First_Record;
execute_query;
last_record;
execute_query;
previous_record;
execute_query;
next_record;
execute_query;
but all wont work it wont goto the next, previous,last and first records.. master plz help me..
micababeHow do I navigate to the last_record after a query has fetched all my records. I jnow it existed the POST-FETCH trigger, but now how can I make this possible?
My problem is simple. I am trying to navigate to the last record of a block after the query has fetched all the records.
Thanks,
Lucian -
I have a last record button and a previous record button and I want when the user reaches the last or first record that a beep occurs. Is there a way to do this cause I put the bell before or after the last_record statement and it didn't work.
Any suggestions?Hi...
Try This.
--- On The First Record Button---
First_Record;
Bell;
--- On The Last Record Button---
Last_Record;
Bell;
Bye
Maybe you are looking for
-
[iPhone] How to change Portrait / Landscape mode.
I am tring to change view mode between portrait and landscape mode. UIViewController has two UIViewes and I want them to be shown as a landscape mode. I found the property of interfaceOrientation in UIViewcontroller. but it is readonly. Is there a wa
-
Runaway RAM Usage leading to Kernel Panic using FilmConvert Plugin (updated x3)
Hello, filed a bug report on this but cuious if anyone sees it. Late 2012 27 iMac, top line i7 with 680MX, 32 GB RAM. Promise R6 TB RAID. Trying to render out a 15 min edit from Premiere that has each clip with 3 filters on it - MB Looks, MB Colorist
-
Nomad Jukebox Zen Xtra PLEASE HE
My player was locked on the EAX screen, and I figured out how to get to the rescue mode, and I clicked "Clean Up" and then pressed the check, and then it went back to the rescue mode screen and nothing's happening. Where do I go from here? What does
-
My wife and I both have Itune accounts in the Istore from which we have purchased music. I recently got a new Mac Mini computer and authorized it with Itunes using my account info. The songs that I purchased previously with my wife's account will not
-
Recipient is not receiving the policy SAP GRC 10 PC
Hello, We have created policy and assigned recipient for policy,when we sent for aproval,approver is sending back the policy to rework with additional comments,but the policy is not coming back to recipients inbox. we have maintained recipient user i