06-02-2011 12:01 PM
Hi exparts,
I writte a BDC program to upload HR master data for tcode PA30.
But I can upload parmanet address with this program.
I want to upload parmanent address then home address .
Can anybody help , how can I upload Parmanent Address & home address by a single BDC program.
Thanks
Edited by: Abu Rayhan on Jun 2, 2011 1:01 PM
06-02-2011 12:21 PM
Hi,
keep the perform statements which are populating for address data inbetween loop and endloop with where condition by personal number.
your file should be like.
personal number(11000011) - permanent address
personalnumber (11000011)- home address.
so the control comes into the loop it checks the where condition(based on personal number), and populate first record with permanent address and save ,populate another record with home address and save.
If you want i will give you the code.
Thanks,
Sriram.
06-04-2011 7:17 AM
HI,
Thanks for replay.
I try to flow you instruction.
But it Overwrite the permanent address.
I can go to home address.
pls send me your code.
Advanced Thanks
Rayhan.
06-06-2011 6:40 AM
Hi...
Pass the subtype also. There will be different subtype for permanent and home address.
Regards,
Jayanth.Y
06-06-2011 6:59 AM
Hi,
Mension the sub type 03 for home address.
Be aware while writting the BDC for dirrerent subtype. According the Subtype different screen is call, due to that some cases BDC is not work. You have to write different condition depends on subtype when necessary.
06-07-2011 5:57 AM
Hi Sriram,
Pls send your code.
Still now I could not solve the problem.
thanks.
06-08-2011 9:55 AM
report ZHR_SMP
no standard page heading line-size 255.
Internal Table TYPE Declaration for keeping Legacy Data
TYPES: BEGIN OF TW_MAIN,
PERNR LIKE RP50G-PERNR,
BEGDA LIKE P0006-BEGDA,
ANSSA LIKE P0006-ANSSA,
STRAS LIKE P0006-STRAS,
ORT01 LIKE P0006-ORT01,
STATE LIKE P0006-STATE,
PSTLZ LIKE P0006-PSTLZ,
LAND1 LIKE P0006-LAND1,
END OF TW_MAIN,
TT_MAIN TYPE STANDARD TABLE OF TW_MAIN.
DATA : WA_MAIN TYPE TW_MAIN,
IT_MAIN TYPE TT_MAIN,
WA_ITEM TYPE TW_MAIN,
IT_ITEM TYPE TT_MAIN,
WA_BDCDATA TYPE BDCDATA,
IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA,
WA_BDCMSGCOLL TYPE BDCMSGCOLL,
IT_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL.
Internal table for enable Required options using Call transaction & Session Method.
DATA: it_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA ls_ctu_params TYPE ctu_params.
DATA : U_MODE(1),
U_UPDT(1),
FNAM(30),
STR TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME TITLE text-001.
PARAMETERS p_fname TYPE localfile OBLIGATORY.
PARAMETERS: p_begcol TYPE i DEFAULT 1,
p_begrow TYPE i DEFAULT 2,
p_endcol TYPE i DEFAULT 20,
p_endrow TYPE i DEFAULT 1600.
SELECTION-SCREEN END OF BLOCK bk1.
SELECTION-SCREEN : BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS : P_FIRST RADIOBUTTON GROUP RB DEFAULT 'X',
P_SECOND RADIOBUTTON GROUP RB,
P_THIRD RADIOBUTTON GROUP RB.
SELECTION-SCREEN : END OF BLOCK B2.
SELECTION-SCREEN : BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
PARAMETERS : P_SYN RADIOBUTTON GROUP RB1,
P_ASYN RADIOBUTTON GROUP RB1 DEFAULT 'X'.
SELECTION-SCREEN : END OF BLOCK B3.
SELECTION-SCREEN : END OF BLOCK B4.
Initialize the work are and internal table body
INITIALIZATION.
PERFORM INTIALIZE_ITAB.
*Get F4 help based on which file need to selected
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
PERFORM GETFILENAME.
START-OF-SELECTION.
Upload the file from Excel to Internal Table
PERFORM FILE_UPLOAD.
Selection Method for Foreground or background or call transactio or session method.
PERFORM SCREEN_FLAG.
Uploading the data from Legacy Sytem to SAP.
PERFORM BDC_TRANSACTION.
END-OF-SELECTION.
&----
*& Form BDC_TRANSACTION
&----
text
----
--> p1 text
<-- p2 text
----
FORM BDC_TRANSACTION.
IT_ITEM = IT_MAIN.
PERFORM CALL_TRANSACTION.
ENDFORM. " BDC_TRANSACTION
&----
*& Form CALL_TRANSACTION
&----
text
----
--> p1 text
<-- p2 text
----
FORM CALL_TRANSACTION .
LOOP AT IT_MAIN INTO WA_MAIN.
CLEAR WA_BDCDATA.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPMP50A' '1300'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'RP50G-PERNR' WA_MAIN-PERNR.
perform bdc_field using 'RP50G-TIMR6' 'X'.
perform bdc_field using 'BDC_CURSOR' 'RP50G-CHOIC'.
perform bdc_field using 'RP50G-CHOIC' '0006'.
perform bdc_dynpro using 'SAPMP50A' '1300'.
perform bdc_field using 'BDC_OKCODE' '=INS'.
perform bdc_field using 'BDC_CURSOR' 'RP50G-PERNR'.
perform bdc_field using 'RP50G-PERNR' WA_MAIN-PERNR.
perform bdc_field using 'RP50G-TIMR6' 'X'.
perform bdc_field using 'RP50G-CHOIC' 'Addresses'.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_CURSOR' '04/03'.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_CURSOR' 'P0006-PSTLZ'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'P0006-BEGDA' WA_MAIN-BEGDA.
perform bdc_field using 'P0006-ENDDA' '12-31-9999'.
perform bdc_field using 'P0006-ANSSA' WA_MAIN-ANSSA.
perform bdc_field using 'P0006-STRAS' WA_MAIN-STRAS.
perform bdc_field using 'P0006-ORT01' WA_MAIN-ORT01.
perform bdc_field using 'P0006-STATE' WA_MAIN-STATE.
perform bdc_field using 'P0006-PSTLZ' WA_MAIN-PSTLZ.
perform bdc_field using 'P0006-LAND1' WA_MAIN-LAND1.
perform bdc_dynpro using 'SAPLSBAL_DISPLAY' '0200'.
perform bdc_field using 'BDC_OKCODE' '=&ONT'.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_CURSOR' 'P0006-STATE'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'P0006-BEGDA' WA_MAIN-BEGDA.
perform bdc_field using 'P0006-ENDDA' '12-31-9999'.
perform bdc_field using 'P0006-ANSSA' WA_MAIN-ANSSA.
perform bdc_field using 'P0006-STRAS' WA_MAIN-STRAS.
perform bdc_field using 'P0006-ORT01' WA_MAIN-ORT01.
perform bdc_field using 'P0006-STATE' WA_MAIN-STATE.
perform bdc_field using 'P0006-PSTLZ' WA_MAIN-PSTLZ.
perform bdc_field using 'P0006-LAND1' WA_MAIN-LAND1.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_OKCODE' '/EBCK'.
perform bdc_field using 'BDC_CURSOR' 'P0006-BEGDA'.
perform bdc_dynpro using 'SAPLSPO1' '0200'.
perform bdc_field using 'BDC_OKCODE' '=YES'.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_CURSOR' 'P0006-PSTLZ'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'P0006-BEGDA' WA_MAIN-BEGDA.
perform bdc_field using 'P0006-ENDDA' '12-31-9999'.
perform bdc_field using 'P0006-ANSSA' WA_MAIN-ANSSA.
perform bdc_field using 'P0006-STRAS' WA_MAIN-STRAS.
perform bdc_field using 'P0006-ORT01' WA_MAIN-ORT01.
perform bdc_field using 'P0006-STATE' WA_MAIN-STATE.
perform bdc_field using 'P0006-PSTLZ' WA_MAIN-PSTLZ.
perform bdc_field using 'P0006-LAND1' WA_MAIN-LAND1.
perform bdc_dynpro using 'SAPLSBAL_DISPLAY' '0200'.
perform bdc_field using 'BDC_OKCODE' '=&ONT'.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_CURSOR' 'P0006-PSTLZ'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'P0006-BEGDA' WA_MAIN-BEGDA.
perform bdc_field using 'P0006-ENDDA' '12-31-9999'.
perform bdc_field using 'P0006-ANSSA' WA_MAIN-ANSSA.
perform bdc_field using 'P0006-STRAS' WA_MAIN-STRAS.
perform bdc_field using 'P0006-ORT01' WA_MAIN-ORT01.
perform bdc_field using 'P0006-STATE' WA_MAIN-STATE.
perform bdc_field using 'P0006-PSTLZ' WA_MAIN-PSTLZ.
perform bdc_field using 'P0006-LAND1' WA_MAIN-LAND1.
perform bdc_dynpro using 'MP000600_CE' '2010'.
perform bdc_field using 'BDC_CURSOR' 'P0006-BEGDA'.
perform bdc_field using 'BDC_OKCODE' '=UPD'.
perform bdc_field using 'P0006-BEGDA' WA_MAIN-BEGDA.
perform bdc_field using 'P0006-ENDDA' '12-31-9999'.
perform bdc_field using 'P0006-ANSSA' WA_MAIN-ANSSA.
perform bdc_field using 'P0006-STRAS' WA_MAIN-STRAS.
perform bdc_field using 'P0006-ORT01' WA_MAIN-ORT01.
perform bdc_field using 'P0006-STATE' WA_MAIN-STATE.
perform bdc_field using 'P0006-PSTLZ' WA_MAIN-PSTLZ.
perform bdc_field using 'P0006-LAND1' WA_MAIN-LAND1.
ls_ctu_params-dismode = U_MODE.
ls_ctu_params-updmode = U_UPDT.
ls_ctu_params-NOBINPT = 'X'.
CALL TRANSACTION 'PA30' USING it_bdcdata
OPTIONS FROM ls_ctu_params MESSAGES INTO IT_BDCMSGCOLL.
PERFORM message.
CLEAR: WA_MAIN, WA_ITEM.
ENDLOOP.
ENDFORM. " CALL_TRANSACTION
&----
*& Form INTIALIZE_ITAB
&----
text
----
--> p1 text
<-- p2 text
----
FORM INTIALIZE_ITAB .
CLEAR: WA_MAIN,
WA_ITEM,
WA_BDCDATA,
WA_BDCMSGCOLL,
LS_CTU_PARAMS.
REFRESH: IT_MAIN,
IT_ITEM,
IT_INTERN,
IT_BDCDATA,
IT_BDCMSGCOLL.
ENDFORM. " INTIALIZE_ITAB
&----
*& Form GETFILENAME
&----
text
----
--> p1 text
<-- p2 text
----
FORM GETFILENAME .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = p_fname.
ENDFORM. " GETFILENAME
&----
*& Form FILE_UPLOAD
&----
text
----
--> p1 text
<-- p2 text
----
FORM FILE_UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_fname
i_begin_col = p_begcol
i_begin_row = p_begrow
i_end_col = p_endcol
i_end_row = p_endrow
TABLES
intern = it_intern.
Moving the data to internal table.
PERFORM MOVE_DATA.
ENDFORM. " FILE_UPLOAD
&----
*& Form MOVE_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM MOVE_DATA .
DATA : lv_index TYPE i.
FIELD-SYMBOLS <fs>.
*--- Sorting the internal table
SORT it_intern BY row col.
CLEAR it_intern.
LOOP AT it_intern.
MOVE it_intern-col TO lv_index.
*--- Assigning the each WA_DATA to an internal table row
ASSIGN COMPONENT lv_index OF STRUCTURE wa_main TO <fs>.
*--- Asigning the field value to a field symbol
MOVE it_intern-value TO <fs>.
AT END OF row.
APPEND wa_main to it_main.
CLEAR wa_main.
ENDAT.
ENDLOOP.
ENDFORM. " MOVE_DATA
&----
*& Form SCREEN_FLAG
&----
text
----
--> p1 text
<-- p2 text
----
FORM SCREEN_FLAG .
IF P_FIRST = 'X'.
U_MODE = 'A'.
ENDIF.
IF P_SECOND = 'X'.
U_MODE = 'N'.
ENDIF.
IF P_THIRD = 'X'.
U_MODE = 'E'.
ENDIF.
IF P_SYN = 'X'.
U_UPDT = 'S'.
ENDIF.
IF P_ASYN = 'X'.
U_UPDT = 'A'.
ENDIF.
ENDFORM. " SCREEN_FLAG
&----
*& Form BDC_DYNPRO
&----
text
----
-->P_0161 text
-->P_0162 text
----
FORM BDC_DYNPRO USING program dynpro.
CLEAR WA_BDCDATA.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM. " BDC_DYNPRO
&----
*& Form BDC_FIELD
&----
text
----
-->P_0211 text
-->P_LW_MAIN_TEXT1 text
----
FORM BDC_FIELD USING FNAM FVAL.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
ENDFORM. " BDC_FIELD
&----
*& Form MESSAGE
&----
text
----
--> p1 text
<-- p2 text
----
FORM MESSAGE .
DATA: MSG TYPE STRING.
LOOP AT IT_BDCMSGCOLL INTO WA_BDCMSGCOLL.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
IMPORTING
MSG = MSG.
IF WA_BDCMSGCOLL-MSGTYP = 'S'.
WRITE:/ MSG,'For',WA_MAIN-PERNR.
ENDIF.
ENDLOOP.
ENDFORM. " MESSAGE
FILE FORMAT:
PERNR BEGDA ANSSA STRAS ORT01 STATE PSTLZ LAND1
10270 8/2/2011 1(Permanent) SSS ban 01 578987 IN
10270 8/2/2011 3(Home) SSS ban 01 578987 IN
06-11-2011 4:48 AM