0% found this document useful (0 votes)
159 views6 pages

Z BDC FB01

The document details the process of uploading transaction data from a file into an SAP system using BDC calls. It defines data structures, performs file upload, and then loops through the records to make BDC calls to populate different transaction screens and save the data.

Uploaded by

Khalid Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views6 pages

Z BDC FB01

The document details the process of uploading transaction data from a file into an SAP system using BDC calls. It defines data structures, performs file upload, and then loops through the records to make BDC calls to populate different transaction screens and save the data.

Uploaded by

Khalid Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

report Z_BDC_FB01

no standard page heading line-size 255.


TABLES : icon.
TYPES : BEGIN OF itab1,
BLDAT TYPE STRING,
BUDAT TYPE STRING,
XBLNR TYPE STRING,
BKTXT TYPE STRING,
NEWBS TYPE STRING,
NEWKO TYPE STRING,
WRBTR TYPE STRING,
BUPLA TYPE STRING,
VALUT TYPE STRING,
ZUONR TYPE STRING,
SGTXT TYPE STRING,
NEWBS1 TYPE STRING,
NEWKO1 TYPE STRING,
GSBER TYPE STRING,
KOSTL TYPE STRING,
WRBTR1 TYPE STRING,
GSBER1 TYPE STRING,
PRCTR TYPE STRING,
END OF itab1.
DATA : itab TYPE STANDARD TABLE OF itab1 WITH HEADER LINE .
*****************************************************************************
DATA : bdcdata TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE .
DATA : messtab TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE .
*****************************************************************************
DATA: BEGIN OF l_intern OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA: END OF l_intern.
DATA : l_index TYPE i,
ctr TYPE i VALUE 0,
l_mstring(480),
s_locnr1(6) TYPE c.
********************************************************************************
*********
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT '' OBLIGATORY. " File Name
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK b4 WITH FRAME TITLE text-014.
PARAMETER : l1 RADIOBUTTON GROUP radi DEFAULT 'X',
l2 RADIOBUTTON GROUP radi .
SELECTION-SCREEN : END OF BLOCK b4 .
******************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* EXPORTING
* PROGRAM_NAME = SYST-REPID
* DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
* STATIC = ' '
* MASK = ' '
CHANGING
file_name = p_file
* EXCEPTIONS
* MASK_TOO_LONG = 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.
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM upload_file TABLES itab
USING p_file.
*BREAK-POINT.
LOOP AT itab.
CLEAR: bdcdata , bdcdata[].
*include bdcrecx1.
*
*start-of-selection.
*
*perform open_group.
*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 'SAPMF05A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BKPF-BLDAT'
ITAB-BLDAT. "'30032011'.
perform bdc_field using 'BKPF-BLART'
'SA'.
perform bdc_field using 'BKPF-BUKRS'
'MTIL'.
perform bdc_field using 'BKPF-BUDAT'
ITAB-BUDAT . " '31032011'.
perform bdc_field using 'BKPF-MONAT'
'1'.
perform bdc_field using 'BKPF-WAERS'
'INR'.
perform bdc_field using 'BKPF-XBLNR'
ITAB-XBLNR. "'Reference'.
perform bdc_field using 'BKPF-BKTXT'
ITAB-BKTXT. "'opening balance'.
perform bdc_field using 'FS006-DOCID'
'*'.
perform bdc_field using 'RF05A-NEWBS'
ITAB-NEWBS. "'40'.
perform bdc_field using 'RF05A-NEWKO'
ITAB-NEWKO . "'47010100'.
*perform bdc_dynpro using 'SAPLSDH4' '0200'.
*perform bdc_field using 'BDC_OKCODE'
* '=GOON'.
*perform bdc_field using 'BDC_CURSOR'
* 'G_SELFLD_TAB-LOW(01)'.
*perform bdc_field using 'DDSHF4CTRL-MAXRECORDS'
* ' 500'.
*perform bdc_field using 'G_SELFLD_TAB-LOW(01)'
* '*PAYMENT*'.
*perform bdc_dynpro using 'SAPMSSY0' '0120'.
*perform bdc_field using 'BDC_CURSOR'
* '04/03'.
*perform bdc_field using 'BDC_OKCODE'
* '=ENTR'.
*break-point.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-WRBTR'
ITAB-WRBTR . "'1500'.
perform bdc_field using 'BSEG-BUPLA'
ITAB-BUPLA ."'DADR'.
perform bdc_field using 'BSEG-VALUT'
ITAB-VALUT . "'31032011'.
perform bdc_field using 'BSEG-ZUONR'
ITAB-ZUONR . "'bank Charges'.
perform bdc_field using 'BSEG-SGTXT'
ITAB-SGTXT . "'Bank charges'.
perform bdc_field using 'RF05A-NEWBS'
ITAB-NEWBS1 . "'50'.
perform bdc_field using 'RF05A-NEWKO'
ITAB-NEWKO1 . "'30002002'.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-KOSTL'.
perform bdc_field using 'BDC_OKCODE'
'=ENTe'.
perform bdc_field using 'COBL-GSBER'
ITAB-GSBER . "'DADR'.
perform bdc_field using 'COBL-KOSTL'
ITAB-KOSTL . "'BAD DEBT'.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-WRBTR'.
perform bdc_field using 'BDC_OKCODE'
'=bu'.
perform bdc_field using 'BSEG-WRBTR'
ITAB-WRBTR1. "'*'.
*perform bdc_field using 'BSEG-BUPLA'
* 'DADR'.
*perform bdc_field using 'BSEG-VALUT'
* '31032011'.
*perform bdc_field using 'BSEG-ZUONR'
* 'bank Charges'.
*perform bdc_field using 'BSEG-SGTXT'
* 'Bank charges'.
perform bdc_field using 'DKACB-FMORE'
'X'.
*perform bdc_dynpro using 'SAPLKACB' '0002'.
*perform bdc_field using 'BDC_CURSOR'
* 'COBL-KOSTL'.
*perform bdc_field using 'BDC_OKCODE'
* '=ENTE'.
*perform bdc_field using 'COBL-GSBER'
* 'dadr'.
*perform bdc_field using 'COBL-KOSTL'
* 'BAD DEBT'.
*Rwenove
*perform bdc_dynpro using 'SAPMF05A' '0300'.
*perform bdc_field using 'BDC_CURSOR'
* 'BSEG-WRBTR'.
*perform bdc_field using 'BDC_OKCODE'
* '=BS'.
*end
*perform bdc_field using 'BSEG-WRBTR'
* '1,500.00'.
*perform bdc_field using 'BSEG-BUPLA'
* 'DADR'.
*perform bdc_field using 'BSEG-VALUT'
* '31.03.2011'.
*perform bdc_field using 'BSEG-ZUONR'
* 'bank Charges'.
*perform bdc_field using 'BSEG-SGTXT'
* 'Bank charges'.
*perform bdc_field using 'DKACB-FMORE'
* 'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-PRCTR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-GSBER'
itab-gsber1 ."'DADR'.
*perform bdc_field using 'COBL-KOSTL'
* itab-kostl1. "'BAD DEBT'.
perform bdc_field using 'COBL-PRCTR'
ITAB-PRCTR. "'OTHERS'.
perform bdc_dynpro using 'SAPMF05A' '0700'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWBS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'BKPF-XBLNR'
* 'REFERENCE'.
*perform bdc_field using 'BKPF-BKTXT'
* 'opening balance'.

If L1 = 'X'.
call transaction 'F-02' using BDCDATA mode 'A' messages into MESSTAB.
elseif L2 = 'X'.
call transaction 'F-02' using BDCDATA mode 'N' messages into MESSTAB.
endif.
perform TRAP_MESSAGES .
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PROGRAM text
* -->DYNPRO text
*----------------------------------------------------------------------*
form BDC_DYNPRO using PROGRAM DYNPRO.
clear BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
append BDCDATA.
endform. "BDC_DYNPRO
****************************************FORM BDC FIELD**************************
*******************
form BDC_FIELD using FNAM FVAL.
clear BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
append BDCDATA.
endform. "BDC_FIELD
********************************************************************************
*********************
****&---------------------------------------------------------------------*
*& Form UPLOAD_FILE
*&---------------------------------------------------------------------*
form UPLOAD_FILE tables P_IT_TAB
using P_FILE.
field-symbols : <FS>.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
FILENAME = P_FILE
I_BEGIN_COL = '1'
I_BEGIN_ROW = '2'
I_END_COL = '256'
I_END_ROW = '60000'
tables
INTERN = L_INTERN
exceptions
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
others = 3.
if SY-SUBRC ne 0.
format color col_background intensified.
write : / 'File Error'.
exit.
endif.
if L_INTERN[] is initial.
format color col_background intensified.
write : / 'No Data Uploaded'.
exit.
else.
sort L_INTERN by ROW COL.
loop at L_INTERN.
move L_INTERN-COL to L_INDEX.
assign component L_INDEX of structure P_IT_TAB to <FS>.
move L_INTERN-VALUE to <FS>.
at end of ROW.
append P_IT_TAB.
clear P_IT_TAB.
endat.
endloop.
endif.
endform. "UPLOAD_FILE
*&---------------------------------------------------------------------*
*& Form TRAP_MESSAGES
*&---------------------------------------------------------------------*
form TRAP_MESSAGES .
data: LINE type I value 0.
data : RED(5) type C,
GREEN(5) type C.
select single ID
from ICON into RED where NAME = 'ICON_LED_RED'.
select single ID
from ICON into GREEN where NAME = 'ICON_LED_GREEN'.
CTR = CTR + 1.
describe table MESSTAB lines LINE.
read table MESSTAB index LINE.
if MESSTAB-MSGTYP = 'S'.
if MESSTAB-MSGV1 <> ' ' .
concatenate GREEN 'BDC INSPECTION PLAN CHANGED' MESSTAB-MSGV1 'CHANGED' i
nto L_MSTRING separated by SPACE.
write:/5 CTR , L_MSTRING(150) .
else.
concatenate RED 'BDC INSPECTION PLAN CHANGED' MESSTAB-MSGV1 'NOT CHANGED'
into L_MSTRING separated by SPACE.
write:/5 CTR , L_MSTRING(150) .
endif.

** elseif MESSTAB-MSGTYP = 'E'.


** concatenate RED 'Net Price Of Info Record' ITAB-KBETR'NOT CHANGED' into L
_MSTRING separated by SPACE.
** write:/5 CTR , L_MSTRING(150) .
* else .
* concatenate 'ARTICLE CHANGED' MESSTAB-FLDNAME into L_MSTRING separated by S
PACE.
*
* write:/5 CTR , L_MSTRING(150) color 5 .
endif.
clear: MESSTAB , MESSTAB[].
endform. "TRAP_MESSAGES
*perform bdc_transaction using 'F-02'.
*
*perform close_group.

You might also like