‎2008 Oct 22 6:07 AM
i have a requirement in transaction xd02, where i have to upload credit card details of customers from an excel file. i created a bdc recording for the same. now, there could be cases where a customer may be holding more than one credit cards. how do i address this issue. where do i loop? the recodring is as below. i have made change to accept kunnr dynamically.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
'0000000545'.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-D0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
'545'.
perform bdc_field using 'RF02D-D0130'
'X'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=CCRD'.
perform bdc_dynpro using 'SAPLV20A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'VCNUM-CCNAME(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENT1'.
perform bdc_field using 'VCNUM-CCNAME(01)'
'Test Customer CAD'.
perform bdc_dynpro using 'SAPLV20A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'VCNUM-CCNAME(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_transaction using 'XD02'.
Edited by: Smit Badai on Oct 22, 2008 10:39 AM
‎2008 Oct 22 6:10 AM
Hi,
Use report prograaming to call this BDC program . One example is shown below..
REPORT zpp0120 NO STANDARD PAGE HEADING
MESSAGE-ID z0
LINE-SIZE 132
LINE-COUNT 65(2).
----
Internal Tables *
----
*Internal table for the BOM file.
DATA: BEGIN OF i_bom OCCURS 0,
matnr(18),
werks(4),
stlan(1),
stlal(2),
stktx(40),
bmeng(16),
menge(16),
posnr(4),
postp(1),
meins(3),
datuv(10),
fmeng(1),
idnrk(18),
potx1(40),
ausch(7),
END OF i_bom.
Extracting Document and Doc type for POSTP = D.
DATA : BEGIN OF i_stpo OCCURS 1,
doknr(25),
dokar(3),
posnr(4),
stlnr LIKE mast-stlnr,
END OF i_stpo.
Local work area
DATA: g_my_rec_in LIKE i_bom.
Declare internal table for Call Transaction and BDC Session
DATA: i_bdc_table LIKE bdcdata OCCURS 0 WITH HEADER LINE.
----
Global Variables *
----
DATA: g_counter(2) TYPE n,
g_field_name(18) TYPE c,
zc_yes TYPE syftype VALUE 'X'.
----
Selection Screen *
----
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_fname1 TYPE localfile .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_rloc1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-005.
PARAMETERS p_group(12) OBLIGATORY DEFAULT 'ZBOM'.
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN END OF BLOCK a.
**WRITE the report header
TOP-OF-PAGE.
INCLUDE zheading.
----
Start of selection *
----
START-OF-SELECTION.
Load Input file
PERFORM f_load_input_file.
Create BDC records.
PERFORM create_bdc_records .
&----
*& Form Create_BDC_records
&----
text:* perform the BDC for the records in the internal table
----
--> p1 text
<-- p2 text
----
FORM create_bdc_records .
DATA: v_stlnr LIKE mast-stlnr.
DATA: v_postp(1) VALUE 'D'.
IF NOT i_bom[] IS INITIAL.
Open BDC session
PERFORM open_bdc_session.
SORT i_bom BY matnr werks posnr.
SELECT SINGLE stlnr INTO v_stlnr
FROM mast
WHERE matnr = i_bom-matnr
AND werks = i_bom-werks.
SELECT doknr dokar posnr stlnr
INTO TABLE i_stpo
FROM stpo
FOR ALL ENTRIES IN i_bom
WHERE postp = v_postp
AND posnr = i_bom-posnr
AND stlnr = v_stlnr.
SORT i_stpo BY posnr stlnr.
LOOP AT i_bom.
g_my_rec_in = i_bom.
READ TABLE i_stpo WITH KEY posnr = i_bom-posnr
stlnr = v_stlnr
BINARY SEARCH.
AT NEW matnr.
CLEAR i_bdc_table[].
PERFORM insert_screen_header.
ENDAT.
Setting up counter for 20 line items
IF g_counter = 20.
g_counter = 1.
ENDIF.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-FMENG(01)'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
CONCATENATE 'RC29P-POSNR(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-posnr.
CONCATENATE 'RC29P-IDNRK(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-idnrk.
CONCATENATE 'RC29P-MENGE(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-menge.
CONCATENATE 'RC29P-MEINS(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-meins.
CONCATENATE 'RC29P-POSTP(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-postp.
CONCATENATE 'RC29P-FMENG(' g_counter ')' INTO g_field_name.
PERFORM bdc_field USING g_field_name i_bom-fmeng.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0130'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
Check the Item category to direct the screen flow accordingly.
CASE i_bom-postp.
WHEN 'B'.
PERFORM item_text_insert.
WHEN 'Z'.
PERFORM item_text_insert.
WHEN 'T'.
PERFORM item_text_insert.
WHEN 'N'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-AUSCH'.
PERFORM bdc_field USING 'RC29P-AUSCH' i_bom-ausch.
next screen
PERFORM item_text_insert.
*next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0133'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RC29P-EKORG' ' '.
WHEN 'D'.
PERFORM bdc_field USING 'RC29P-DOKNR' i_stpo-doknr.
PERFORM bdc_field USING 'RC29P-DOKAR' i_stpo-dokar.
next screen
PERFORM item_text_insert.
When POSTP = X, L.
WHEN OTHERS.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-AUSCH'.
PERFORM bdc_field USING 'RC29P-AUSCH' i_bom-ausch.
next screen
PERFORM item_text_insert.
ENDCASE.
g_counter = g_counter + 1.
next screen
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR' 'RC29P-POSNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE' '=FCBU'.
AT END OF matnr.
PERFORM insert_bdc_new.
ENDAT.
ENDLOOP.
CLEAR i_bom[].
PERFORM close_bdc_session.
Release the BDC sessions created
PERFORM release_bdc.
ENDIF.
ENDFORM. " open_group
&----
*& Form bdc_dynpro_start
&----
Initialize the screen
----
-->P_G_PROGRAM_1
-->P_G_SCREEN
----
FORM bdc_dynpro USING p_g_program_1
p_g_screen.
CLEAR i_bdc_table.
i_bdc_table-program = p_g_program_1.
i_bdc_table-dynpro = p_g_screen.
i_bdc_table-dynbegin = 'X'.
APPEND i_bdc_table.
ENDFORM. " bdc_dynpro_start
&----
*& Form bdc_field
----
Insert field *
----
FORM bdc_field USING f_name f_value.
CLEAR i_bdc_table.
i_bdc_table-fnam = f_name.
i_bdc_table-fval = f_value.
APPEND i_bdc_table.
ENDFORM. "bdc_insert_field
regards
Mudit
‎2008 Oct 22 6:12 AM
in this case you have to loop the creditcard infomration and append the bdc records. i hope it s a table control. just check any tablecontrol handling example. you can get lot of examples in SCN or google
search with "handling tablecontrol in BDC"
‎2008 Oct 22 6:15 AM
Hi,
loop at i_tab into wa_tab.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-KUNNR'.
perform bdc_field using 'RF02D-KUNNR'
wa_tab-kunnr.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-D0130'.
perform bdc_field using 'RF02D-KUNNR'
wa_tab-kunnr.
perform bdc_field using 'RF02D-D0130'
'X'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=CCRD'.
perform bdc_dynpro using 'SAPLV20A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'VCNUM-CCNAME(01)'.
perform bdc_field using 'VCNUM-CCNAME(01)'
wa_tab-ccname.
perform bdc_field using 'BDC_OKCODE'
'=ENT1'.
perform bdc_dynpro using 'SAPLV20A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'VCNUM-CCNAME(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_dynpro using 'SAPMF02D' '0130'.
perform bdc_field using 'BDC_CURSOR'
'KNBK-BANKS(01)'.
perform bdc_transaction using 'XD02'. or if you have this also in the internal table put this in as wa_tab-banks
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
endloop.
Where i_tab is the internal table which contains all the kunnr, ccname and banks data.
Regards,
Pooja
‎2008 Oct 22 6:16 AM
Hi SMIT,
Heraty Welcome to SDN community.
Here customer id is primary key. so you just rewrite the same data in your excel sheet with differt credit card number might upload with out any extra coding. say this is my sample excel sheet.
kunnr credit_card_No
1 011
1 012
1 013
2 018
So the customer 1 having 3 credit cards but customer number is one which is primary key because of which it can be stored only once but credit card numbers will be saved.
After trying revert back whether it has worked or not.
Cheers!!
Balu
Edited by: Balu CH on Oct 22, 2008 10:47 AM
‎2008 Oct 22 6:19 AM
Hi,
1st of all u have to decide a way, how to make the excel file....
1. according to me, make the excel file in such a war, where if a customer have more than one card...make two rows of all same value except the card number...
2. in the BDC program, after uploading the excel file to internal table... find all the card numbers for a customer...
3. in the BDC (perform bdc_field using 'VCNUM-CCNAME(01)')
for the 1st card use 'VCNUM-CCNAME(01)'
for the 2nd card use 'VCNUM-CCNAME(02)'
for the 2nd card use 'VCNUM-CCNAME(03)'
dynamically change VCNUM-CCNAME(..)
i think this will solve ur problem...