Skip to Content
0
Jun 15, 2015 at 03:51 PM

re: how to capture iblnr,gjahr using mi01 tcode in bdc

47 Views

Hi Experts

/h

i have developed a bdc code to generate physical document number using mi01 tcode. once iblnr is generated how to

capture iblnr , gjahr and update this values into ztable. here is my code

report ZBDCMIO1

no standard page heading line-size 255.

TABLES: RM07I,

IKPF,

ZMI01.

DATA: BEGIN OF it_final OCCURS 0,

bldat(20),

gidat(20),

werks(10),

lgort(10),

sperr(4),

xlvOca(4),

xblni(20),

head(4) TYPE c,

matnr(20),

END OF it_final.

DATA: BEGIN OF it_final1 OCCURS 0,

IBLNR TYPE IBLNR,

GJAHR TYPE GJAHR,

END OF it_final1.

data: it_bdcdata TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE,

w_file1 TYPE string,

v_ind(2) TYPE n,

it_msg TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE,

v_matnr(30) TYPE c.

PARAMETERS: filename LIKE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = filename.

*include bdcrecx1.

start-of-selection.

w_file1 = filename.

*perform open_group.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file1

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_final.

loop at it_final where head = 'H'.

perform bdc_dynpro using 'SAPMM07I' '0700'.

perform bdc_field using 'BDC_CURSOR'

'IKPF-SPERR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RM07I-BLDAT'

* '13.06.2008'.

it_final-bldat.

perform bdc_field using 'RM07I-GIDAT'

* '13.06.2008'.

it_final-gidat.

perform bdc_field using 'IKPF-WERKS'

* '0005'.

it_final-werks.

perform bdc_field using 'IKPF-LGORT'

* '0001'.

it_final-lgort.

perform bdc_field using 'IKPF-SPERR'

* 'X'.

it_final-sperr.

perform bdc_field using 'RM07I-XLVOCA'

* 'X'.

it_final-xlvoca.

v_ind = 01.

loop at it_final where head ne 'H'.

* v_ind = v_ind + 1.

CONCATENATE 'ISEG-MATNR' '(' V_IND ')' INTO V_MATNR.

perform bdc_dynpro using 'SAPMM07I' '0721'.

perform bdc_field using 'BDC_CURSOR'

* 'ISEG-MATNR(01)'.

V_MATNR.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using V_MATNR "'ISEG-MATNR(01)'

* 'T-AC0101'.

IT_FINAL-MATNR.

perform bdc_dynpro using 'SAPMM07I' '0721'.

perform bdc_field using 'BDC_CURSOR'

* 'ISEG-MATNR(01)'.

V_MATNR.

perform bdc_field using 'BDC_OKCODE'

'/00'.

*perform bdc_field using 'ISEG-MATNR(01)'

* 'T-AC0201'.

**perform bdc_dynpro using 'SAPMM07I' '0721'.

**perform bdc_field using 'BDC_CURSOR'

*** 'ISEG-MATNR(01)'.

** V_MATNR.

**perform bdc_field using 'BDC_OKCODE'

** '=POAN'.

**IF V_IND = 02.

** V_IND = 01.

** ENDIF.

ENDLOOP.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

call transaction 'MI01' using it_bdcdata mode 'A' update 'A' messages into it_msg.

*perform bdc_transaction using 'MI01'.

*perform close_group.

ENDLOOP.

*--------------------------------------------------------------------*

* Start new screen *

*----------------------------------------------------------------------*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR it_BDCDATA.

it_BDCDATA-PROGRAM = PROGRAM.

it_BDCDATA-DYNPRO = DYNPRO.

it_BDCDATA-DYNBEGIN = 'X'.

APPEND it_BDCDATA.

ENDFORM.

*----------------------------------------------------------------------*

* Insert field *

*----------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

* IF FVAL <> NODATA.

CLEAR it_BDCDATA.

it_BDCDATA-FNAM = FNAM.

it_BDCDATA-FVAL = FVAL.

APPEND it_BDCDATA.

* ENDIF.

ENDFORM.

/h

with warm regards

nagaraj