Handling sessions in BDC
Hi all,
What do we code to create a new session in BDC Call transaction method.
Let me explain the situation in brief.
I have an issue where in i need to upload 5000 records. As per requirement i am supposed to upload only 1000 per session. Please let me know how to create new session dynamically and move the processed data to sessions. And also let me know how to handle the errors in those records after processing 500 records.
I know that Message_format is the FM to know to errors but I need to handle them dynamically.
Guess we need to go by session method to handle errors but how to do that dynamically.
Thanks and Regards
Amit.
Hi Amit,
Suppose all your records are in table infile.
Keep a counter such that when each record in the table is processed, the counter is incremented.
When 1000 records are processed, call the insert bdc function. Reset the function.
Thus dynamically you create 5 sessions if there are five records.
In the following table, I am creating bdc sessions for the transaction FBV1. It has two screens.
1000 for the first screen(header details) and 3000 for all other records(line item details)
LOOP AT infile.
PERFORM create_bdc.
ENDLOOP.
IF abend_job = false.
PERFORM format_scrn_0300_last.
PERFORM insert_bdcdata.
ENDIF.
form create_bdc.
sy-subrc = 0.
IF new_bdc EQ true.
PERFORM open_bdc.
IF abend_job = true.
EXIT.
ENDIF.
ENDIF.
IF first_time = true.
CLEAR ba_cnt_tab.
PERFORM format_scrn_0100. /* to process first screen
PERFORM format_break_fields.
ELSEIF detail_rec_cnt = 999. /* When the number of records is 999 process the last record and insert the session
PERFORM format_scrn_0300_last.
PERFORM insert_bdcdata.
IF abend_job = false.
MOVE: true TO bdc_tab_created.
PERFORM format_scrn_0100. /* Again call the header screen and put the header details.
PERFORM format_break_fields.
ENDIF.
ELSE.
PERFORM format_scrn_0300_detail. /* Processing of Details records otherwise.
PERFORM format_break_fields.
ENDIF.
IF abend_job = false.
IF first_time = true.
MOVE: true TO bdc_tab_created,
false TO first_time.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDFORM.
Format Break Fields
FORM format_break_fields.
This form format fields necessary for breaking logic and postions
the BA_CNT_TAB at the Business Area being processed.
MOVE: infile-cost_center TO prev_cost_center,
infile-business_area TO prev_business_area,
infile-amount TO prev_amount,
infile-dollar_amt TO prev_dollar_amt,
infile-order+2(12) TO prev_order,
infile-wbs_element TO prev_wbs_element,
infile-text TO prev_text,
infile-due_on_date TO prev_due_on_date.
SHIFT prev_order LEFT DELETING LEADING space.
ENDFORM.
format screen 0100
FORM format_scrn_0100.
This form contains the logic to create screen 0100
sy-subrc = 0.
IF ba_cnt_tab-business_area NE infile-business_area.
Position BA_CNT_TAB at business area currently processing.
LOOP AT ba_cnt_tab.
IF ba_cnt_tab-business_area = infile-business_area.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
PERFORM dynpro_saplf040_0100 USING infile-post_key infile-accnt.
ENDFORM.
FORMAT SCREEN 0300 FOR LAST DETAIL
FORM format_scrn_0300_last.
This form formats the last detail screen 0300 and a phantom entry
if needed. Screen 0002 is also formatted for each 0300.
ADD: prev_dollar_amt TO phantom_accum,
1 TO detail_rec_cnt.
IF prev_dollar_amt GT 0.
ADD: prev_dollar_amt TO amt_debit_added.
ELSE.
ADD: prev_dollar_amt TO amt_credit_added.
ENDIF.
IF detail_rec_cnt LT ba_cnt_tab-rec_cnt.
IF phantom_accum LT 0.
Reverse posting key since being posted as an offset to the accumulated
Amount.
MOVE debit_pk TO posting_key.
num_data = phantom_accum * -1.
ELSE.
MOVE credit_pk TO posting_key.
num_data = phantom_accum.
ENDIF.
PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
prev_due_on_date posting_key phantom_accnt.
PERFORM dynpro_saplkacb_0002 USING prev_cost_center
prev_business_area prev_order prev_wbs_element.
MOVE num_data TO char_data.
PERFORM dynpro_saplf040_0300 USING char_data '' '' '' ''.
PERFORM bdc_value USING 'BDC_OKCODE' post.
PERFORM dynpro_saplkacb_0002 USING ' ' prev_business_area ' ' ' '.
ELSE.
PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
prev_due_on_date '' ''.
PERFORM bdc_value USING 'BDC_OKCODE' post.
PERFORM dynpro_saplkacb_0002 USING prev_cost_center
prev_business_area prev_order prev_wbs_element.
ENDIF.
CLEAR: detail_rec_cnt,
phantom_accum.
ENDFORM.
FORMAT DETAIL FOR SCREEN 0300
FORM format_scrn_0300_detail.
This FORM formats screen 0300 for a detail record along with its
screen 0002
ADD: prev_dollar_amt TO phantom_accum.
PERFORM dynpro_saplf040_0300 USING prev_amount prev_text
prev_due_on_date infile-post_key infile-accnt.
PERFORM dynpro_saplkacb_0002 USING prev_cost_center
prev_business_area prev_order prev_wbs_element.
IF prev_dollar_amt LT 0.
ADD: prev_dollar_amt TO amt_credit_added.
ELSE.
ADD: prev_dollar_amt TO amt_debit_added.
ENDIF.
ADD: 1 TO detail_rec_cnt.
ENDFORM.
Dynpro for program SAPMF05A Screen 0100
FORM dynpro_saplf040_0100 USING post_key post_accnt.
This FORM formats SCREEN 0100
This PERFORM is done once for each screen.
PERFORM bdc_dynpro USING 'SAPLF040' '0100'.
This PERFORM is done as many times as there are fields to be
populated for the screen being processed.
PERFORM bdc_value USING 'BKPF-BLDAT' header-doc_mdy.
PERFORM bdc_value USING 'BKPF-BUDAT' header-post_mdy.
PERFORM bdc_value USING 'BKPF-BLART' header-doc_type.
PERFORM bdc_value USING 'BKPF-BUKRS' header-company_code.
PERFORM bdc_value USING 'BKPF-MONAT' header-period.
PERFORM bdc_value USING 'BKPF-WAERS' header-currency.
PERFORM bdc_value USING 'BKPF-XBLNR' header-reference_doc.
PERFORM bdc_value USING 'BKPF-BKTXT' header-text.
*Begin of change by Priya Vasudevan for including checkbox
PERFORM BDC_VALUE USING 'VBKPF-XBWAE' CONTROL.
*End of change
IF header-rate NE space.
PERFORM bdc_value USING 'BKPF-KURSF' header-rate.
ENDIF.
IF header-translation_date NE space.
PERFORM bdc_value USING 'BKPF-WWERT' header-translation_date.
ENDIF.
PERFORM bdc_value USING 'RF05V-NEWBS' post_key.
PERFORM bdc_value USING 'RF05V-NEWKO' post_accnt.
ENDFORM.
Dynpro for program SAPLF040 Screen 0300
FORM dynpro_saplf040_0300 USING amount text due_on_date
post_key post_accnt.
This FORM formats SCREEN 0300
This PERFORM is done once for each screen.
PERFORM bdc_dynpro USING 'SAPLF040' '0300'.
This PERFORM is done as many times as there are fields to be
populated for the screen being processed.
PERFORM bdc_value USING 'BSEG-WRBTR' amount.
*Begin of change by Priya Vasudevan for addition of assign no and tax .
PERFORM BDC_VALUE USING 'BSEG-ZUONR' ASSIGNMENT_NUMBER.
PERFORM BDC_VALUE USING 'BKPF-XMWST' TAX_CALCULATE.
*End of change
PERFORM bdc_value USING 'RF05V-NEWBS' post_key.
PERFORM bdc_value USING 'RF05V-NEWKO' post_accnt.
IF due_on_date NE space.
PERFORM bdc_value USING 'BSEG-ZFBDT' due_on_date.
ENDIF.
IF text NE space.
PERFORM bdc_value USING 'BSEG-SGTXT' text.
ENDIF.
ENDFORM.
Dynpro for program SAPLKACB Screen 0002
FORM dynpro_saplkacb_0002 USING cost_center business_area order wbs.
This FORM formats SCREEN 0002 WHICH IS A POP-UP SCREEN
THAT DOES NOT APPEAR DURING ON-LINE PROCESSING
This PERFORM is done once for each screen.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
This PERFORM is done as many times as there are fields to be
populated for the screen being processed.
IF cost_center NE space.
PERFORM bdc_value USING 'COBL-KOSTL' cost_center.
ENDIF.
IF business_area NE space.
PERFORM bdc_value USING 'COBL-GSBER' business_area.
ENDIF.
IF order NE space.
PERFORM bdc_value USING 'COBL-AUFNR' order.
ENDIF.
IF wbs NE space.
PERFORM bdc_value USING 'COBL-PS_PSP_PNR' wbs.
ENDIF.
ENDFORM.
BDC Dynpro
FORM bdc_dynpro USING pgm scrn.
This FORM formats the transaction that tells the BDC which screen is
to be populated.
CLEAR bdc_tab.
MOVE: pgm TO bdc_tab-program,
scrn TO bdc_tab-dynpro,
begin TO bdc_tab-dynbegin.
APPEND bdc_tab.
ENDFORM.
BDC Value
FORM bdc_value USING field val.
This FORM tells the BDC which field is to be populated and the value
to use.
CLEAR bdc_tab.
MOVE: field TO bdc_tab-fnam,
val TO bdc_tab-fval.
APPEND bdc_tab.
ENDFORM.
FORM open_bdc.
This routine opens the BDC data file
sy-subrc = 0.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = group_name
keep = 'X'
user = sy-uname
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11.
IF sy-subrc NE 0.
MOVE: true TO abend_job.
CASE sy-subrc.
WHEN 01.
PERFORM process_msg USING '109' sy-mandt 'BDC OPEN' ''.
WHEN 02.
PERFORM process_msg USING '109' 'BDC OPEN' '' ''.
WHEN 03.
PERFORM process_msg USING '111' 'BDC OPEN' '' ''.
WHEN 04.
PERFORM process_msg USING '124' 'BDC OPEN' '' ''.
WHEN 05.
PERFORM process_msg USING '112' 'BDC OPEN' '' ''.
WHEN 06.
PERFORM process_msg USING '113' 'BDC OPEN' '' ''.
WHEN 07.
PERFORM process_msg USING '114' 'BDC OPEN' '' ''.
WHEN 08.
PERFORM process_msg USING '115' 'BDC OPEN' '' ''.
WHEN 09.
PERFORM process_msg USING '125' 'BDC OPEN' '' ''.
WHEN 10.
PERFORM process_msg USING '116' 'BDC OPEN' '' ''.
WHEN 11.
PERFORM process_msg USING '126' 'BDC OPEN' '' ''.
ENDCASE.
ELSE.
MOVE: true TO bdc_openned,
false TO new_bdc.
ENDIF.
ENDFORM.
Insert BDC data
FORM insert_bdcdata.
This routine inserts a scenario into the BDC batch session.
Add the actual value of the particular Transaction code relevant
to the scenario being processed for the constant TRANS_CODE.
sy-subrc = 0.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = trans_code
TABLES
dynprotab = bdc_tab
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
OTHERS = 5.
IF sy-subrc NE 0.
MOVE: true TO abend_job.
CASE sy-subrc.
WHEN 01.
PERFORM process_msg USING '113' 'BDC INSERT' '' ''.
WHEN 02.
PERFORM process_msg USING '117' 'BDC INSERT' '' ''.
WHEN 03.
PERFORM process_msg USING '114' 'BDC INSERT' '' ''.
WHEN 04.
PERFORM process_msg USING '118' 'BDC INSERT' '' ''.
WHEN 05.
PERFORM process_msg USING '126' 'BDC INSERT' '' ''.
ENDCASE.
ELSE.
bdc_trans_cnt = bdc_trans_cnt + 1.
ENDIF.
Initialize table after inserting the processed BDC Transactions
for one scenario
REFRESH bdc_tab.
ENDFORM.
End of Job Routine
FORM eoj_routine.
IF bdc_openned = true.
PERFORM close_bdc.
IF bdc_tab_created = true AND
abend_job = false.
TRANSLATE submit TO UPPER CASE.
IF submit = 'X'.
PERFORM submit_bdc_to_batch.
ELSE.
CLEAR : msg1, msg2, msg3.
CONCATENATE 'Session' group_name INTO msg1 SEPARATED BY space.
msg2 = 'has been created. '.
msg3 = 'Please use SM35 to process the session.'.
MESSAGE i150 WITH msg1 msg2 msg3 .
ENDIF.
IF abend_job = false.
PERFORM update_date_control_file.
ENDIF.
ENDIF.
ENDIF.
IF abend_job = true.
PERFORM abend_job.
PERFORM alert_check.
ELSE.
These writes are an example of control totals that would be included
on a control report.
PERFORM: process_msg USING '174' total_recs '' 'NC',
process_msg USING '176' bdc_trans_cnt '' 'NC',
process_msg USING '148' tot_debit '' 'NC',
process_msg USING '149' tot_credit '' 'NC',
process_msg USING '173' interface_id '' ''.
WRITE: /1 ' End of Job Run'.
TRANSLATE temp_unix_name TO LOWER CASE.
SHIFT full_fil_name UP TO temp_unix_name+0(9).
SUBMIT zuxmv WITH filename EQ full_fil_name
WITH frompath EQ temp_unix_path
WITH to_path EQ temp_arc_path
exporting list to memory
AND RETURN.
ENDIF.
SUBMIT zuxlp WITH filename = temp_log_name
WITH path = temp_log_path
WITH printer = temp_printer
exporting list to memory
AND RETURN.
IF abend_job = true.
IF execution = 'ONLINE'.
PERFORM process_msg USING '100' in_trailer-interface_id '' ''.
MESSAGE a100 WITH in_trailer-interface_id.
ENDIF.
ENDIF.
CLOSE DATASET logfile.
ENDFORM.
Close BDC data
FORM close_bdc.
This routine closes the BDC batch session.
sy-subrc = 0.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MOVE: true TO abend_job.
CASE sy-subrc.
WHEN 01.
PERFORM process_msg USING '117' 'BDC CLOSE' '' ''.
WHEN 02.
PERFORM process_msg USING '114' 'BDC CLOSE' '' ''.
WHEN 03.
PERFORM process_msg USING '126' 'BDC CLOSE' '' ''.
ENDCASE.
ENDIF.
ENDFORM.
Submit BDC to Batch
FORM submit_bdc_to_batch.
This FORM submits the completed BDC Table to Batch to be processed
for all the transactions processed from the Interface input file.
Changes made by sthomas on 11.16.2005
SUBMIT rsbdcsub WITH mappe EQ group_name
with Z_VERARB EQ 'X'
*Code inserted by sthomas on 16.11.2005
WITH fehler EQ ' '
EXPORTING LIST TO MEMORY
AND RETURN.
WAIT UP TO 2 SECONDS.
SELECT * UP TO 1 ROWS INTO TABLE i_apqi
FROM apqi
WHERE groupid = group_name
AND credate <= sy-datum
AND cretime <= sy-uzeit
ORDER BY cretime DESCENDING.
READ TABLE i_apqi INDEX 1.
clear : msg1, msg2, msg3.
concatenate 'Session' group_name into msg1 SEPARATED BY SPACE.
IF i_apqi-qstate = 'F'.
msg2 = 'has been successfully processed'.
MESSAGE i150 WITH msg1 msg2.
ELSEIF i_apqi-qstate = 'E'.
msg2 = 'has been processed with errors.'.
msg3 = 'Please use SM35 to view the errors'.
MESSAGE i150 WITH msg1 msg2 msg3 .
ELSE.
msg2 = 'has been transferred to the background for'.
msg3 = 'processing. Please use SM35 to view the status'.
MESSAGE i150 WITH msg1 msg2 msg3.
ENDIF.
End of code.
End of change
ENDFORM.
Update date control file
FORM update_date_control_file.
This routine will update the Interface Date/Time Control File with
the Date/Time Stamp of the current file just processed successfully.
The parameter FILE_OPERATION indicates that the control file is to
be updated with the new stamp and the status of the Interface/file
will be set to 'C' for complete.
CALL FUNCTION 'Z_PROCESS_INTERFACE_CTL_TABLE'
EXPORTING
file_id = in_trailer-interface_id
file_name = in_trailer-file_name
file_date = in_trailer-date
file_time = in_trailer-time
file_operation = '2'
EXCEPTIONS
dup_file_error = 1
file_id_not_found = 2
table_not_updated = 3
OTHERS = 4.
IF sy-subrc NE 0.
MOVE: true TO abend_job.
CASE sy-subrc.
WHEN 01.
PERFORM process_msg USING '127' in_trailer-interface_id
in_trailer-file_name 'OPERATION 2'.
WHEN 02.
PERFORM process_msg USING '128' in_trailer-interface_id
in_trailer-file_name 'OPERATION 2'.
WHEN 03.
PERFORM process_msg USING '129' 'ZTAG' '' ''.
WHEN 04.
PERFORM process_msg USING '126' 'OPERATION 2' '' ''.
ENDCASE.
ENDIF.
ENDFORM.
Abend Job
FORM abend_job.
This form updates the Interface Date/Time Control File with a status
of 'A' to indicate that this Interface has abended. The Date/Time
stamp on the Control file will not be updated with the date/time
from the current file. The parameter FILE_OPERATION OF '3' initiates
this process. Any time Operation '3' is used with the
Date/Time Control File, the calling program must abend using an 'A'
Message. A generic abend message of 100 has been set up in the
T100 table.
CALL FUNCTION 'Z_PROCESS_INTERFACE_CTL_TABLE'
EXPORTING
file_id = in_trailer-interface_id
file_name = in_trailer-file_name
file_date = in_trailer-date
file_time = in_trailer-time
file_operation = '3'
EXCEPTIONS
dup_file_error = 1
file_id_not_found = 2
table_not_updated = 3
OTHERS = 4.
IF sy-subrc NE 0.
CASE sy-subrc.
WHEN 01.
PERFORM process_msg USING '127' in_trailer-interface_id
in_trailer-file_name 'OPERATION 3'.
WHEN 02.
PERFORM process_msg USING '128' in_trailer-interface_id
in_trailer-file_name 'OPERATION 3'.
WHEN 03.
PERFORM process_msg USING '129' 'ZTAG' 'OPERATION 3' ''.
WHEN 04.
PERFORM process_msg USING '126' 'OPERATION 3' '' ''.
ENDCASE.
ENDIF.
PERFORM process_msg USING '100' in_trailer-interface_id '' ''.
ENDFORM.
INCLUDE zi000002.
Feel free to ask any doubt in this logic.
Regards,
Susmitha
Similar Messages
-
Handling popups in bdc recording
Hi,
I am doing bdc recording for a transaction, and there is a popup screen to be handled by the user, but when i am doing recording it is not recording the popup menus. can you please tel me how i can handle popups in BDC recording.
It is very urgent.
Thank you.Hi Ameen,
Award points if useful...
Step by Step approach to ceate simple BDC session program using reusable template.
This step by step approach can be used to create a Simple BDC program i.e for a transaction which does not have any table control / looping at screen table. The same can also be enhanced to develop a program for transactions involving table controls .
1. Create a new program as executable program using SE38 transaction code.
2. Copy the following template code into your program .
---- Start of Template -
REPORT NO STANDARD PAGE HEADING LINE-SIZE 200 LINE-COUNT 300.
*-- DATA DECLARATION--
*---Types
DATA : BEGIN OF t_upload,
FIELD1(10),
FIELD2(2),
FIELD3(18),
FIELD4(35),
END OF t_upload.
*--- Tables
DATA : BEGIN OF i_bdcdata OCCURS 0."to hold the transaction record
INCLUDE STRUCTURE bdcdata.
DATA: END OF i_bdcdata.
DATA: i_upload LIKE STANDARD TABLE OF t_upload," to hold file data.
i_upload1 LIKE STANDARD TABLE OF t_upload." to hold file data.
*--- Work Areas
DATA: wa_upload2 LIKE t_upload,
wa_upload LIKE t_upload,
wa_upload1 LIKE t_upload.
*--- Variables
DATA: v_count1(4) TYPE n,
v_error TYPE c,
v_session(12),
v_field(21) TYPE c,
v_message(60) type 'C'.
*--Constants
DATA: c_open TYPE c VALUE '(',
c_close TYPE c VALUE ')',
c_x TYPE c VALUE 'X'.
*---Initialisation
initialization.
refresh : i_upload , i_upload1 ,i_bdcdata.
-------Selection Screen Design -
*Selection screen for input of upload file address
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
---AT SELECTION SCREEN -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*--For popup to select file.
PERFORM give_help.
-----START OF SELECTION -
START-OF-SELECTION.
*--Data upload using WS_Upload.
PERFORM get_data.
*-- OPEN SESSION
PERFORM open_group.
*--Insert transactions using BDCDATA table in the session.
PERFORM do_transaction .
*-- Close the session.
PERFORM close_group.
END-OF-SELECTION.
*& Form f_get_data
For data upload from external file.
FORM get_data.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = i_upload
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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
DELETE I_UPLOAD INDEX 1.
ENDIF.
ENDFORM. " f_get_data
*& Form F_open_group
To open session in session management.
FORM open_group.
v_session = 'TCODE'.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = v_session
user = sy-uname
keep = 'X'.
ENDFORM. " F_open_group
*& Form f_do_transaction
Insert transactions in session after passing values to BDCDATA
FORM do_transaction.
LOOP AT i_upload INTO wa_upload .
*---- insert your generated codes from recording at SHDB here
*----- insertion ends
perform bdc_transaction using 'TCODE'.
REFRESH : I_BDCDATA.
CLEAR : WA_UPLOAD.
ENDIF.
ENDLOOP.
ENDFORM. " f_do_transaction
*& Form bdc_dynpro
For appending screen details to BDCDATA
FORM bdc_dynpro USING program dynpro.
CLEAR i_bdcdata.
i_bdcdata-program = program.
i_bdcdata-dynpro = dynpro.
i_bdcdata-dynbegin = 'X'.
APPEND i_bdcdata.
CLEAR i_bdcdata.
ENDFORM. "bdc_dynpro
*& Form bdc_field
For appending field details to bdcdata table
FORM bdc_field USING fnam fval.
CLEAR i_bdcdata.
i_bdcdata-fnam = fnam.
i_bdcdata-fval = fval.
APPEND i_bdcdata.
CLEAR i_bdcdata.
ENDFORM. " bdc_field
*& Form bdc_transaction
For inserting Transaction in the session
FORM bdc_transaction USING tcode.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
TABLES
dynprotab = i_bdcdata.
ENDFORM. " bdc_transaction
*& Form F_close_group
For closing the session created in Session manager SM35
FORM close_group.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
concatenate 'Session ' v_session 'successfully created' into v_field.
MESSAGE v_field type 'I'..
CALL TRANSACTION 'SM35'.
ENDFORM. "f_close_group
*& Form f_give_help
For user help to select file
FORM give_help.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
mask = ',.,..'
mode = 'O'
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0 AND NOT sy-msgty IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f_give_help
---- End of Template -
3.Go to the transaction SHDB in another session ( you can also give TCODE - OSHDB in transaction code window and hit enter ).
4.Create you transaction recording in SHDB . Ensure your transaction recording takes care of input values to all the
fields to which you intend to pass values in the BDC.
5.Once your recording is done correctly create the program from recording in the SHDB transction . You will find the button to create program in SHDB . Choose the option of creating from file when you proceed through the subsequent steps.
6. Define data type t_upload and structure wa_upload in the template program with fields of structure 'RECORD' from the program generated using SHDB recording ( replace the field1, field2 and so on as per your requirement). For your understanding you can remove the suffixes to the
field name but keep the field size unchanged.
7.Copy the coding existing between 'do' and 'enddo' statement from the generated program . Insert the copied code between the loop and endloop code of form 'Do_transaction '. Replace fields of structure 'RECORD' with respective fields of structure wa_upload.Insert constant values wherever possible in transaction recording.You can also handle customised data conversions here.
8.Replace 'TCODE' in the template program with the transaction code you intend to process in this BDC.
9.Please carry out further syntax check and resolve the related issues.
This program will provide for input help to select upload file from local machine. The file needs to be in Tab delimited format and is assumed to have first row as column headers .
On successful creation of session you will be prompted with a Information popup giving the name of session ,and will take you to the SM35 transaction to process your session. -
Hi,
How to handle errors in bdc call transaction method.
what is the steps to download errors from bdcmsgcoll into flat file in call transaction method
udayHi friend,
Here is a beautiful example which explains how to trap erroreneous records ..if help full then please give me max reward point.
REPORT zgopi_report
NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZRASH.
Internal Table Declarations *
*--Internal Table for Data Uploading.
DATA : BEGIN OF IT_FFCUST OCCURS 0,
KUNNR(10),
BUKRS(4),
KTOKD(4),
ANRED(15),
NAME1(35),
SORTL(10),
STRAS(35),
ORT01(35),
PSTLZ(10),
LAND1(3),
SPRAS(2),
AKONT(10),
END OF IT_FFCUST.
*--Internal Table to Store Error Records.
DATA : BEGIN OF IT_ERRCUST OCCURS 0,
KUNNR(10),
EMSG(255),
END OF IT_ERRCUST.
*--Internal Table to Store Successful Records.
DATA : BEGIN OF IT_SUCCUST OCCURS 0,
KUNNR(10),
SMSG(255),
END OF IT_SUCCUST.
*--Internal Table for Storing the BDC data.
DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*--Internal Table for storing the messages.
DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_FLAG1(1) VALUE ' ',
"Flag used for opening session.
V_TLINES LIKE SY-TABIX,
"For storing total records processed.
V_ELINES LIKE SY-TABIX,
"For storing the no of error records.
V_SLINES LIKE SY-TABIX.
"For storing the no of success records.
Selection screen *
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
V_SESNAM LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
Start-of-selection *
START-OF-SELECTION.
*-- Form to upload flatfile data into the internal table.
PERFORM FORM_UPLOADFF.
TOP-OF-PAGE *
TOP-OF-PAGE.
WRITE:/ 'Details of the error and success records for the transaction'
ULINE.
SKIP.
End of Selection *
END-OF-SELECTION.
*-- Form to Generate a BDC from the Uploaded Internal table
PERFORM FORM_BDCGENERATE.
*--To write the totals and the session name.
PERFORM FORM_WRITEOP.
*& Form form_uploadff
Form to upload flatfile data into the internal table.
FORM FORM_UPLOADFF .
*--Variable to change the type of the parameter file name.
DATA : LV_FILE TYPE STRING.
LV_FILE = V_FNAME.
*--Function to upload the flat file to the internal table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = IT_FFCUST
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.
*--Deleting the headings from the internal table.
DELETE IT_FFCUST INDEX 1.
*--Getting the total number of records uploaded.
DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
ENDIF.
ENDFORM. " form_uploadff
*& Form Form_bdcgenerate
Form to Generate a BDC from the Uploaded Internal table
FORM FORM_BDCGENERATE .
*--Generating the BDC table for the fields of the internal table.
LOOP AT IT_FFCUST.
PERFORM POPULATEBDC USING :
'X' 'SAPMF02D' '0105',
' ' 'BDC_OKCODE' '/00' ,
' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
'X' 'SAPMF02D' '0110' ,
' ' 'BDC_OKCODE' '/00',
' ' 'KNA1-ANRED' IT_FFCUST-ANRED,
' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
' ' 'KNA1-SORTL' IT_FFCUST-SORTL,
' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
'X' 'SAPMFO2D' '0120',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0125',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0130',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0340',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0360',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0210',
' ' 'KNB1-AKONT' IT_FFCUST-AKONT,
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0215',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0220',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0230',
' ' 'BDC_OKCODE' '=UPDA'.
*--Calling the transaction 'fd01'.
CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
MESSAGES INTO IT_CUSTMSG.
IF SY-SUBRC <> 0.
*--Populating the error records internal table.
IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_ERRCUST.
CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
IF V_FLAG1 = ' '.
PERFORM FORM_OPENSESSION.
V_FLAG1 = 'X'.
ENDIF.
*--Inserting the error records into already open session.
IF V_FLAG1 = 'X'.
PERFORM FORM_INSERT.
ENDIF.
*--Populating the Success records internal table.
ELSE.
IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_SUCCUST.
CLEAR IT_SUCCUST.
ENDIF.
*--Displaying the messages.
IF NOT IT_CUSTMSG[] IS INITIAL.
PERFORM FORM_FORMATMSG.
ENDIF.
*--Clearing the message and bdc tables.
CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
ENDLOOP.
*--Getting the total no of error records.
DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
IF V_FLAG1 = 'X'.
PERFORM FORM_CLOSESESS.
ENDIF.
ENDFORM. " Form_bdcgenerate
*& Form populatebdc
FOrm to Populate the BDC table.
FORM POPULATEBDC USING VALUE(P_0178)
VALUE(P_0179)
VALUE(P_0180).
IF P_0178 = 'X'.
IT_CUSTBDC-PROGRAM = P_0179.
IT_CUSTBDC-DYNPRO = P_0180.
IT_CUSTBDC-DYNBEGIN = 'X'.
ELSE.
IT_CUSTBDC-FNAM = P_0179.
IT_CUSTBDC-FVAL = P_0180.
ENDIF.
APPEND IT_CUSTBDC.
CLEAR IT_CUSTBDC.
ENDFORM. " populatebdc
*& Form FORM_OPENSESSION
Form to Open a session.
FORM FORM_OPENSESSION .
*--Variable to convert the given session name into reqd type.
DATA : LV_SESNAM(12).
LV_SESNAM = V_SESNAM.
*--Opening a session.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LV_SESNAM
HOLDDATE = '20040805'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
IF SY-SUBRC <> 0.
WRITE :/ 'Session not open'.
ENDIF.
ENDFORM. " FORM_OPENSESSION
*& Form FORM_INSERT
fORM TO INSERT ERROR RECOED INTO A SESSION.
FORM FORM_INSERT .
*--Inserting the record into session.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FD01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_CUSTBDC
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF SY-SUBRC <> 0.
WRITE :/ 'Unable to insert the record'.
ENDIF.
ENDFORM. " FORM_INSERT
*& Form FORM_CLOSESESS
Form to Close the Open Session.
FORM FORM_CLOSESESS .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " FORM_CLOSESESS
*& Form FORM_FORMATMSG
Form to format messages.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
DATA : LV_MSG(255).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE :/ LV_MSG.
ENDIF.
ULINE.
ENDFORM. " FORM_FORMATMSG
*& Form form_writeop
To write the totals and the session name.
FORM FORM_WRITEOP .
WRITE :/ 'Total Records Uploaded :',V_TLINES,
/ 'No of Error Records :',V_ELINES,
/ 'No of Success Records :',V_SLINES,
/ 'Name of the Session :',V_SESNAM.
ULINE.
ENDFORM. " form_writeop -
Best way to handle session timeout
Hello All,
oracle 11g, Apex ver 3.1.2
I am bit confused about the sessoin handling mecahnism for the users .
Which is the best way to handle session for the users is it programatically or by DBA admin level.
What are the pros and cons going DBA Level and Programmatica level.
Before hand I got to have some information on hand for justification.
thanks/kumarHi,
I've done a great deal of work with mobile accounts in Snow Leopard and I'm now having a "play" with Lion. To be honest you have to sit down and think about why you need mobile accounts.
If your user only uses one computer then your safer having a local account backed up by a network Time Machine, this avoids the many many woes that the Servers FileSyncAgent brings to the table.
If your users are going to be accessing multiple computers on the network and leaving the network then a mobile account is good for providing a uniform user experience and access to files etc. However, your users will have to make a choice as to whether they want their iPhoto libraries on one Local machine (backed up by Time Machine) or whether they want their library to be hosted on the server and not part of the Mobile Home Sync schedule (adding ~/Pictures to the excluded items on the home sync settings).
With the latter, users will be able to access their iPhoto libraries on any computer when they are within the network (as it's accessed from the users server home folder).
With the first option the user would have their iPhoto library on one computer (say the laptop they used the most) but then would not be able to access it from other computers they log on to.
iPhoto libraries are a pain, and I'm working hard to come up with a workaround. If your users moved over to using Apeture then you could include the aperture library as part of the home sync thanks to Deeport (http://deepport.net/archives/os-x-portable-home-directories-and-syncing-flaw-wit h-bundles/)
He does suggest that the same would work with IPhoto libraries - but it doesn't for a number of mysterious reasons regarding how the OS recognizes thie iPhoto bundle (it does so differently compared to Apeture).
Hope this helps... -
Handling sessions (identifying, mapping)
Hi.
I'm still new to handling sessions and users with javax.servlet.*
Two questions, one about identifying one other about mapping :
-how do you access the user login name ? The object HttpSession.getId() tells me nothing interesting, because this id changes everytime the user connects
-in a project where there are information about the user (say a UserAccount class) to be mapped to him, in what piece of code do you code the bind action? I'm using the FORM memory realm, from TOMCAT. Is it possible to bind objects to a user with this kind of authentication?
Thanks!If you are using FORM based authentication then you can get the userid of the logged user using the following:
1.
String userid = request.getRemoteUser();OR
2.
java.security.Principal user = request.getUserPrincipal();
String userid = user.getName();
Where request is HttpServletRequest -
Handling sessions in Web Services
Hi all,
I am quite new to Web Services. I am facing problems in handling sessions in Web Services.
I am using Apache Axis as SOAP engine. I have different Web Services like AuthenticationService, DataService and ReportService.
The problem is in handling authentication. I need to authenticate only once using AuthenticationService and maintain the
session for rest of the calls to different web services like DataService, ReportService.
Has anyone faced similar situation?
Please help.
Thanks,
Prashantha bit unspecific, anyway, here a solution for a plain JAX-RPC implementation
in a JAX-RPC client, use
((javax.xml.rpc.Stub)myProxy)._setProperty(javax.xml.rpc.Stub.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
to let the client maintain session state
in JAX-RPC server, implement ServiceLifecycle and call getHttpSession() on the servlet endpoint context
Merten -
Handling Session in jsp and bean scope
i have problems with handling session in jsp
I want to check on all jsp pages
first thing is session is null
i want to him to be redirected to first page
and he should not be able to go ahead
I tried
if(session ==null)
response.sendRedirect("Login.jsp");
but this does not seem to work
It is very crtical problem can any one answer
this asap
Also i wanted to know that
I have bean which in turn calls static methods of another class which holds all DomainTable(database tables which do not change frequently)
Information .
This is bean is being implemented by me
in seession scope in a jsp
Do u guys think it would be goo idea to change
scop of this bean as Application in jsp
if so what would be advantages for same
I would appericate if i could a quick reply on both
question
as i am time crunch
arshYou will always get some value of session and your code wont work. At the end of your Login.jsp, you should create a sesssion and store attributes. Check for these attributes in session, rather than checking session==null.
-
Can we create multiple session in BDC using Call session?
Hi Experts,
Can we create multiple sessions in BDC using Call Session?
Scenario:
Program has to upload 1 million records,so can we programmatically create multiple sessions such that after every 50thousand records we create a different session.
For moment due to large number of records BDC DYNPRO and BDC Field are unable to hold the large number of records,due to which we get a Out of memory error.
Thanks in advance.
ShilpaHi
If ITAB is your table with the data to be transfered:
Open the first session:
CALL FUNCTION 'BDC_OPEN_GROUP'.........
IF SY-SUBRC = 0.
FL_OPEN = 'X'.
ENDIF.
LOOP AT ITAB.
IF FL_OPEN = SPACE.
Create new session
CALL FUNCTION 'BDC_OPEN_GROUP'.........
IF SY-SUBRC = 0.
FL_OPEN = 'X'.
ENDIF.
ENDIF.
Here elaborate your data and fill BDCDATA
Insert the transaction:
CALL FUNCTION 'BDC_INSERT'
IF SY-SUBRC = 0.
COUNT = COUNT + 1.
IF COUNT = COUNT_MAX.
COUNT = 0.
Close the session
IF FL_OPEN = 'X'.
CALL BDC_CLOSE_GROUP
IF SY-SUBRC = 0.
FL_OPEN = SPACE.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
Max -
I am using JDeveloper 11.1.1.6.
I am trying to gracefully handle session time outs in ADF. My application has been experiencing the 'canned' ADF session timeout popup when I am logged into my application and the session has timed out. That same popup is rendered even if I am sitting at my login page but haven't signed in.
I have followed Frank Nimphius's guidance as explained in the following forum to have my application re-direct to the login page after session timeout. That works great thanks to his well detailed document.
ADF Faces : session timeout best practice
The concern I have now is if I am sitting at my login page and my session times out, the application stays at the login page. I now type my credentials and click log in. Because the application thinks my session is timed out, I am taken back to the login page. Ideally I wouldn't think the login page would hold a session. Do you have any guidance on how I can get around this.Hi,
what about using programmatic login, in which case the login form is part of a public page (see http://www.oracle.com/technetwork/issue-archive/2012/12-jan/o12adf-1364748.html for an example you can download)
Frank -
hi,
how to handle popups in bdc.
it is very urgent.
thanks in advance...bdc.
some time bdc ok_code can't set for popup.
so Manually set.
screen no.
bdc_ok code..
else.
check backgrounf sucessful run or not.
after set bdc ok_code. -
How to handle tabstrips in BDC
Hi All,
Can anyone please let me know how to handle Tabstrips in BDC (Here Subscreen comes into picture).
Please give me advice on this any one, it is very urgent, please help me.
Many Thanks in Advance for u r Answer
NarenJust use ABAPDOCU Transaction and see the complex screen menu,there you will find out example program for Tab strips.
for bdc point of view you need to do recording propery and copy the code .
only changes you need to do get the data from file to internal table.
use loop ur internal table ,withinin internal table paste ur code(screens,program name) and it should work.
Reward Points if it is useful
Thanks
Seshu -
Handle Session data with JAX-WS web services
Is it posible to to handle session tracking with JAX-WS web services without implementing my own session logic.
If posible how do we put values in to session and get them back.
And also assuming that sessions are supported is it posible to share the same session between two web services on the same web application.Hello!
Do you have any solution to your problem now? I also need to maintain a session bean between 2 webservices. If you solved this, can you please tell me how?
Thanks a lot! -
How to perform Error Handling in this Bdc Code
Hi,
I had created this BDC for the tcode MB1B and i want to know how to perform the ERROR HANDLING in it ..
Plzz provide me guidelines for doing it . here's d code:-
report ZBDC_MB1B
no standard page heading line-size 255.
include bdcrecx1.
data: begin of record OCCURS 0,
WERKS_001(004), "Plant
MATNR_002(018), "ItemId
ERFMG_003(013), "Quantity in Unit of Entry
ERFME_004(003), "Unit of Entry
LGORT_005(004), "Storage Location
CHARG_006(010), "BatchId
KDAUF_007(010), "Sales Order Number
KDPOS_008(006), "Item Number in Sales Order
end of record.
PARAMETERS : P_FILNAM LIKE RLGRAP-FILENAME.
initialization.
CTUMODE = 'A'.
CUPDATE = 'A'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILNAM.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = ',. '
MODE = 'O'
IMPORTING
FILENAME = P_FILNAM
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 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.
start-of-selection.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILNAM
FILETYPE = 'DAT'
TABLES
DATA_TAB = RECORD
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
NO_AUTHORITY = 10
OTHERS = 11
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT RECORD.
BEGIN OF SCREEN 1
perform bdc_dynpro using 'SAPMM07M' '0400'.
perform bdc_field using 'BDC_CURSOR'
'RM07M-SOBKZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'MKPF-BLDAT'
'22.12.2008'.
*perform bdc_field using 'MKPF-BUDAT'
'22.12.2008'.
perform bdc_field using 'RM07M-BWARTWA'
'411'.
perform bdc_field using 'RM07M-SOBKZ'
'E'.
perform bdc_field using 'RM07M-WERKS'
RECORD-WERKS_001. "Plant
perform bdc_field using 'XFULL'
'X'.
perform bdc_field using 'RM07M-WVERS2'
'X'.
BEGIN OF SCREEN 2
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-CHARG(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MSEG-MATNR(01)'
RECORD-MATNR_002. "ITEMID
perform bdc_field using 'MSEG-ERFMG(01)'
RECORD-ERFMG_003. "QTY.
perform bdc_field using 'MSEG-ERFME(01)'
RECORD-ERFME_004. "UOM
perform bdc_field using 'MSEG-LGORT(01)'
RECORD-LGORT_005. "ST.LOC
perform bdc_field using 'MSEG-CHARG(01)'
RECORD-CHARG_006. "BATCHID
perform bdc_field using 'MSEGK-MAT_KDAUF'
RECORD-KDAUF_007. "S.O.
perform bdc_field using 'MSEGK-MAT_KDPOS'
RECORD-KDPOS_008. "S.O.LINE ITEM
perform bdc_field using 'DKACB-FMORE'
'X'.
BEGIN OF SCREEN 3
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-ERFMG(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'DKACB-FMORE'
'X'.
BEGIN OF SCREEN 4
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_transaction using 'MB1B'.
ENDLOOP.hi,
check this code in bold letters.
INCLUDE BDCRECX1.
TABLES : MARC.
TYPES : BEGIN OF TY_UPLOAD,
MATNR TYPE MARA-MATNR,
WERKS TYPE MARC-WERKS,
STEUC TYPE MARC-STEUC,
END OF TY_UPLOAD.
TYPES : BEGIN OF TY_MARC,
MATNR TYPE MARA-MATNR,
WERKS TYPE MARC-WERKS,
END OF TY_MARC.
TYPES : BEGIN OF TY_MTART,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
END OF TY_MTART.
DATA : T_MARC TYPE STANDARD TABLE OF TY_MARC,
: T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD,
: T_BASIC TYPE STANDARD TABLE OF TY_UPLOAD,
: T_SALES TYPE STANDARD TABLE OF TY_UPLOAD,
: T_ERROR TYPE STANDARD TABLE OF TY_UPLOAD.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDCDATA_VIEW LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_DATA(3200) OCCURS 0 WITH HEADER LINE,
IT_FIELD(3200) OCCURS 0 WITH HEADER LINE,
IT_BDCMSG TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA GI_MSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : CHAR1(500),
CHAR2(500),
CHAR3 TYPE STRING,
V_SELECTION TYPE STRING. " For View Selection
DATA : W_MARC TYPE TY_MARC,
WA_UPLOAD TYPE TY_UPLOAD,
WA_BASIC TYPE TY_UPLOAD,
WA_SALES TYPE TY_UPLOAD,
WA_ERROR TYPE TY_UPLOAD,
WA_MTART TYPE TY_MTART.
DATA : VAR TYPE N,
VAR1 TYPE STRING.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. "SELECTION SCREEN
PARAMETERS: P_FNAM LIKE RLGRAP-FILENAME.
PARAMETERS: P_BAS LIKE RLGRAP-FILENAME.
PARAMETERS: P_SAL LIKE RLGRAP-FILENAME.
PARAMETERS: P_ERR LIKE RLGRAP-FILENAME.
SELECTION-SCREEN : END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAM.
PERFORM SEARCH USING P_FNAM.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BAS.
PERFORM SEARCH USING P_BAS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_SAL.
PERFORM SEARCH USING P_SAL.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_ERR.
PERFORM SEARCH USING P_ERR.
*& Form SEARCH
text
-->PFNAME text
FORM SEARCH USING PFNAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
STATIC = 'X'
CHANGING
FILE_NAME = PFNAME.
ENDFORM. "SEARCH
START-OF-SELECTION.
PERFORM UPLOAD_PROCESS USING P_FNAM.
PERFORM OPEN_GROUP.
PERFORM PROCESS.
PERFORM CLOSE_GROUP.
IF NOT T_BASIC[] IS INITIAL.
PERFORM DOWNLOAD TABLES T_BASIC[] USING P_BAS .
ENDIF.
IF NOT T_SALES[] IS INITIAL.
PERFORM DOWNLOAD TABLES T_SALES[] USING P_SAL .
ENDIF.
IF NOT T_ERROR[] IS INITIAL.
PERFORM DOWNLOAD TABLES T_ERROR[] USING P_ERR.
ENDIF.
*& Form PROCESS
text
FORM PROCESS.
LOOP AT T_UPLOAD INTO WA_UPLOAD.
PERFORM CONV_ROUTINE USING WA_UPLOAD-MATNR
CHANGING WA_UPLOAD-MATNR.
SELECT COUNT(*) FROM MARA WHERE MATNR = WA_UPLOAD-MATNR.
IF SY-SUBRC NE 0.
MOVE-CORRESPONDING WA_UPLOAD TO WA_BASIC.
APPEND WA_BASIC TO T_BASIC.
CLEAR WA_BASIC.
CONTINUE.
ENDIF.
SELECT COUNT(*) FROM MARC WHERE MATNR = WA_UPLOAD-MATNR
AND WERKS = WA_UPLOAD-WERKS
AND PSTAT LIKE '%V%'.
IF SY-SUBRC NE 0.
MOVE-CORRESPONDING WA_UPLOAD TO WA_SALES.
APPEND WA_SALES TO T_SALES.
CLEAR WA_SALES.
CONTINUE.
ENDIF.
CLEAR : WA_MTART.
SELECT SINGLE MATNR MTART FROM MARA INTO WA_MTART WHERE MATNR = WA_UPLOAD-MATNR.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=AUSW'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
WA_UPLOAD-MATNR.
CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW' " Function module
EXPORTING
MATERIAL = WA_UPLOAD-MATNR " Material number
MATERIALART = WA_MTART-MTART " Material Type
SELECTION = 'V' "
TCODE = 'MM02' " Tcode where view's are called.
TABLES
BTCI_D0070 = IT_BDCDATA_VIEW
EXCEPTIONS
MATERIAL_NOT_FOUND = 1
MATERIAL_NUMBER_MISSING = 2
MATERIAL_TYPE_MISSING = 3
MATERIAL_TYPE_NOT_FOUND = 4
NO_ACTIVE_DYNPRO_SELECTED = 5
NO_AUTHORITY = 6
OTHERS = 7.
READ TABLE IT_BDCDATA_VIEW WITH KEY FVAL = 'X'.
IF SY-SUBRC = 0.
V_SELECTION = IT_BDCDATA_VIEW-FNAM.
ELSE.
CONTINUE.
ENDIF.
VAR = IT_BDCDATA_VIEW-FNAM+17(2).
VAR = VAR + 3.
CONCATENATE 'MSICHTAUSW-KZSEL(' '0' VAR ')' INTO VAR1.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(06)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING VAR1
'X'.
CLEAR VAR.
CLEAR VAR1.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(06)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0080'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-VKORG'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'RMMG1-WERKS'
WA_UPLOAD-WERKS.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4004'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
'MTI_ESE_HALB_01'.
PERFORM BDC_FIELD USING 'MARC-STEUC'
WA_UPLOAD-STEUC.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MARC-HERKR'.
PERFORM BDC_FIELD USING 'MARC-HERKL'
'IN'.
PERFORM BDC_FIELD USING 'MARC-HERKR'
'MAH'.
PERFORM BDC_TRANSACTION USING 'MM02'.
move the error record into seperate internal table nad down load it ****
IF MESSTAB-MSGTYP = 'E'.
MOVE-CORRESPONDING WA_UPLOAD TO WA_ERROR.
APPEND WA_ERROR TO T_ERROR.
CLEAR WA_ERROR.
ENDIF.
ENDLOOP.
ENDFORM. "PROCESS
*& Form UPLOAD_PROCESS
text
-->PFNAME text
FORM UPLOAD_PROCESS USING PFNAME.
DATA : PFNAME1 TYPE STRING.
PFNAME1 = PFNAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = PFNAME1
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = T_UPLOAD[].
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. "UPLOAD_PROCESS
*& Form CONV_ROUTINE
text
-->P_INPUT text
-->P_OUTPUT text
FORM CONV_ROUTINE USING P_INPUT
CHANGING P_OUTPUT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_INPUT
IMPORTING
OUTPUT = P_OUTPUT.
ENDFORM. "CONV_ROUTINE
*& Form DOWNLOAD
text
-->GI_FINAL text
-->PFNAME text
FORM DOWNLOAD TABLES
GI_FINAL
USING PFNAME .
DATA : FNAME TYPE STRING.
FNAME = PFNAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = FNAME
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = 'x'
HEADER = '00'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = GI_FINAL[]
FIELDNAMES = GI_FIELDNAMES[]
IF SY-SUBRC = 0.
MESSAGE 'FILE DOWNLOADED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDFORM. " DOWNLOAD
Regards
Siva Prasad -
How to handle session-timeout in producer-consumer(wsrp) environment.
Hi
We are using weblogic portal 9.2 in federated environment (wsrp) .
We have one consumer Ear and some producer Ear .
we want if session is time out ,then user should direct to some default page .
For that we are firing event in Base Exception handler where we caught all exceptions.
that event is listen by consumer side ,(when session time out producer raise event).
event is fired , every thing looks fine but we are not able to redirect page from producer to consumer (which should not be happen )
I think we are doing something wrong .
Any suggestion/ guidance will help us lot
thanks in advanceHello,
Probably the easiest way for you to get the behaviour you want would be to put a event handler on a .portlet file (on the consumer) that lives on the page you want to activate if the producer session has timed out. For example:
<netuix:handleCustomEvent event="eventNameComingFromProducer" eventLabel="sessionTimeoutPageActivation">
<netuix:activatePage/>
</netuix:handleCustomEvent>
When your producer portlet sends an event "eventNameComingFromProducer" the portlet on the page you want to activate will pick it up and automatically activate the page.
Kevin -
Handling session in ADF application
We're going to develop an application using ADF BC, JDev 11.1.1.2.0 and Weblogic 10.3. My idea is to put user specific information in a bean with session scope. I have couple of stored procedures to do some DML operations for user related data like profile, order information, etc. User logins first and multiple users may call the same procedure to insert or update or delete something. How ADF handles this scenario? Do I have to handle locking manually? If yes where and how? Thanks.
Hi,
ADF has the web session managed by the container. This means that a managed bean is available to the user for as long the session does not expiry (web.xml configuration) or is getting invalidated. ADF does nothing specifcally here
if you use prepared statements to access the database then locking is not automatically handled, same for releaing the database connect. You don''t give more hints in your question, so I can't give more information in my answer. Note that if you need to make resources or information available to all usres of an application, then application scope may be better to use than a session scope. E.g. the database access could be coded in a managed bean in application scope so that the acces is shared betwene users (just no user specific state should be saved in there)
Frank
Maybe you are looking for
-
HT1414 Ipod Mini not working after trying to update to IOS7
Team Apple....HELP! I recently tried to in tall the new IOS 7 on my Mini Ipad....but I get the connect to Itunes with USB cable on the screen. I've intalled the latest updates to the OS on my MAC Laptop and the latest version of Itunes. Itunes saw a
-
File to IDoc - How to proceed further?
Hi everybody, Consider the following scenario, <Header> <Transaction> <Meterpoint> <Address></Address> <Asset> <Meter></Meter> <Conversion></Conversion> <Register></Register> </Asset>
-
Alignment problem on abap report after Unicode conversion
Hi, I've recently convert my system to unicode. Now my user is complaining the aged debtor report (ABAP) is having a column alignment problem when displaying the Japanese character. I'm not sure what to do now. Have anyone experience this and let me
-
Where can i find documentation on Forte 3.0?
Hi Folks! i'm lookin' for all the documentation about Forte for Java 3.0, CE about all the features, old and new can anybody tell me the right url to find it? thanks all
-
How outbound idoc of message type WMMBXY is created? any program or FM name
Hello Gurus, How outbound idoc of message type WMMBXY is created? any program or FM name?? basic type : WMMBID01... i checked the idoc in my system, it does not have any process code.... also, i checked the exit : EXIT_SAPLMBMB_001. It has some code