Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8800

BDC for F-03

$
0
0

Hi,

 

i've written the following code for a creating a bdc for f-03, however  only the first docuement is being fetched from the flat file.

Please suggest the corrections to be made.

 

  AGKON TYPE RF05A-AGKON  ,       "Account Number or Key of a Worklist
   BUDAT TYPE BKPF-BUDAT   ,       "Posting Date
   MONAT TYPE BKPF-MONAT   ,       "Fiscal Period
   BUKRS TYPE BKPF-BUKRS   ,       "Company Code
   WAERS TYPE BKPF-WAERS   ,       "Currency
   SEL01 TYPE RF05A-SEL01  ,       "Input Field for Search Criterion for Selecting Open Items

END OF ty_file.

DATA :  wa_file TYPE ty_file,
         it_file TYPE TABLE OF ty_file.

DATA :  WA_BDCMSGCOLL TYPE BDCMSGCOLL,
         IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.

DATA :  WA_BDCDATA TYPE BDCDATA,
         IT_BDCDATA TYPE TABLE OF BDCDATA.

TYPES  : BEGIN OF TY_MSG  ,
           MSG  TYPE STRING  ,
          END OF TY_MSG  .

DATA  :  IT_MSG  TYPE TABLE OF TY_MSG  ,
          WA_MSG  TYPE TY_MSG  .

DATA : msg TYPE string.

*********** PARAMETER FOR I/P FILE***********************************
PARAMETERS  :  p_file TYPE rlgrap-filename .

DATA  :  v_file TYPE string .

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENTS   - validate user input                  *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

   CALL FUNCTION 'F4_FILENAME'
     EXPORTING
       program_name  = syst-cprog
       dynpro_number = syst-dynnr
       field_name    = ' '
     IMPORTING
       file_name     = p_file.

*----------------------------------------------------------------------*
* START OF SELECTION                                                   *
*----------------------------------------------------------------------*
START-OF-SELECTION .

   IF p_file IS NOT INITIAL .    "if its not empty
     v_file  =  p_file  .
   ENDIF .

PERFORM upload_bdcdata.

PERFORM CALL_TRANSACTION.

PERFORM MESSAGES.

*&---------------------------------------------------------------------*
*&      Form  UPLOAD_BDCDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM UPLOAD_BDCDATA .

  REFRESH it_file .

   CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
      filename                      = v_file
      filetype                      = 'ASC'
      has_field_separator            = 'X'

     TABLES
       data_tab                      = it_file
    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.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " UPLOAD_BDCDATA

*&---------------------------------------------------------------------*
*&      Form  CALL_TRANSACTION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CALL_TRANSACTION .

**include bdcrecx1.
**
**start-of-selection.

**perform open_group.

LOOP AT it_file INTO wa_file.

   REFRESH it_bdcdata.

perform bdc_dynpro      using 'SAPMF05A' '0131'.
perform bdc_field       using 'BDC_CURSOR'        'RF05A-XPOS1(03)'.
perform bdc_field       using 'BDC_OKCODE'        '=PA'.
perform bdc_field       using 'RF05A-AGKON'       wa_file-agkon.     "'150000'.
perform bdc_field       using 'BKPF-BUDAT'        wa_file-budat.     "'21.07.2013'.
perform bdc_field       using 'BKPF-MONAT'        wa_file-monat.     "'4'.
perform bdc_field       using 'BKPF-BUKRS'        wa_file-bukrs.     "'1800'.
perform bdc_field       using 'BKPF-WAERS'        wa_file-waers.     "'INR'.
perform bdc_field       using 'RF05A-XPOS1(01)'   ''.
perform bdc_field       using 'RF05A-XPOS1(03)'   'X'.

perform bdc_dynpro      using 'SAPMF05A' '0731'.
perform bdc_field       using 'BDC_CURSOR'        'RF05A-SEL01(02)'.
perform bdc_field       using 'BDC_OKCODE'         '=PA'.
perform bdc_field       using 'RF05A-SEL01(01)'    wa_file-sel01.    "'110000085'.
*perform bdc_field       using 'RF05A-SEL01(02)'    '110000050'.
perform bdc_dynpro      using 'SAPDF05X' '3100'.

perform bdc_field       using 'BDC_OKCODE'         '=OMA'.
perform bdc_field       using 'BDC_CURSOR'         'RFOPS_DK-BELNR(02)'.
perform bdc_field       using 'RF05A-ABPOS'        '1'.
perform bdc_dynpro      using 'SAPDF05X' '3100'.

perform bdc_field       using 'BDC_OKCODE'         '=OMA'.
perform bdc_field       using 'BDC_CURSOR'         'RFOPS_DK-BELNR(01)'.
perform bdc_field       using 'RF05A-ABPOS'        '1'.
perform bdc_dynpro      using 'SAPDF05X' '3100'.

perform bdc_field       using 'BDC_OKCODE'          '=BU'.
perform bdc_field       using 'BDC_CURSOR'          'RFOPS_DK-BELNR(01)'.
perform bdc_field       using 'RF05A-ABPOS'         '1'.
perform bdc_dynpro      using 'SAPDF05X' '3100'.

perform bdc_field       using 'BDC_OKCODE'          '=PI'.
perform bdc_field       using 'BDC_CURSOR'          'DF05B-PSBET(03)'.
perform bdc_field       using 'RF05A-ABPOS'         '1'.
perform bdc_dynpro      using 'SAPDF05X' '3100'.

perform bdc_field       using 'BDC_OKCODE'           '=BS'.
perform bdc_field       using 'BDC_CURSOR'           'DF05B-PSBET(03)'.
perform bdc_field       using 'RF05A-ABPOS'          '1'.
perform bdc_dynpro      using 'SAPMF05A' '0700'.

perform bdc_field       using 'BDC_CURSOR'           'RF05A-NEWBS'.
perform bdc_field       using 'BDC_OKCODE'           '=BU'.
**perform bdc_transaction using 'F-03'.
**
**perform close_group.

CALL TRANSACTION 'F-03' USING it_bdcdata
                         MODE 'A'            "'E'
                         UPDATE 'S'
                         MESSAGES INTO it_bdcmsgcoll.

ENDLOOP.
ENDFORM.                    " CALL_TRANSACTION

*----------------------------------------------------------------------*
*        START NEW SCREEN                                              *
*----------------------------------------------------------------------*
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

*----------------------------------------------------------------------*
*        INSERT FIELD                                                  *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
*  IF FVAL <> NODATA.
   CLEAR WA_BDCDATA.
   WA_BDCDATA-FNAM = FNAM.
   WA_BDCDATA-FVAL = FVAL.
   APPEND WA_BDCDATA TO IT_BDCDATA.
*  ENDIF.
ENDFORM.                    "BDC_FIELD
*&---------------------------------------------------------------------*
*&      Form  MESSAGES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MESSAGES .

   LOOP AT it_bdcmsgcoll INTO wa_bdcmsgcoll.
     CALL FUNCTION 'FORMAT_MESSAGE'
      EXPORTING
        ID              = wa_bdcmsgcoll-MSGID
        LANG            = wa_bdcmsgcoll-msgspra                                           "'-D'
        NO              = wa_bdcmsgcoll-MSGNR
        V1              = wa_bdcmsgcoll-MSGV1
        V2              = wa_bdcmsgcoll-MSGV2
        V3              = wa_bdcmsgcoll-MSGV3
        V4              = wa_bdcmsgcoll-MSGV4
      IMPORTING
        MSG             = wa_msg-msg
      EXCEPTIONS
        NOT_FOUND       = 1
        OTHERS          = 2 .
     IF sy-subrc <> 0.
       APPEND wa_msg TO it_msg .           "* Implement suitable error handling here
     ENDIF.

    IF it_msg IS NOT INITIAL.
     LOOP AT it_msg INTO wa_msg.
       WRITE : / wa_msg-msg.
     ENDLOOP.
    ELSE.
      WRITE : / 'ERROR MESSAGE' .
    ENDIF.

   ENDLOOP.

ENDFORM.                    " MESSAGES

 

Regards,

Charmaine


Viewing all articles
Browse latest Browse all 8800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>