Skip to Content
author's profile photo Former Member
Former Member

flat file

hi gurus

could u plz send me a flat file used for BDC using line items

good points will be rewarded

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2008 at 04:04 PM

    hi,

    you are saying flat file for line items.

    But line items for what :

    line items may be for sales order, purchase order.

    So, do one thing.

    Create one text document. Jus give the field values seperated by tab space.(these field valuse should correspond to the screen fields and internal table fields).

    If you want BDC sample code : Im giving it here.

    ***********************************************************************

    • Report : Z50871MM_BDCP_ASSIGNMENT3 *

    • Title : BDC PROGRAM TO UPLOAD VENDOR DATA *

    • Author : SANDEEP REDDY *

    • Date of Creation : November 30, 2007 *

    ***********************************************************************

    • Modification Log *

    • Author : *

    • Date of Change : *

    • Functional Specs # : *

    • Correction Request # : *

    • Description of Change : *

    ***********************************************************************

    REPORT z50871mm_bdcp_assignment3 NO STANDARD PAGE HEADING

    LINE-SIZE 255.

    ----


    • STRUCTURE DECLARATION

    ----


    TYPES : BEGIN OF st_vendor,

    ktokk TYPE rf02k-ktokk, "account group

    anred TYPE lfa1-anred, "title

    name1 TYPE lfa1-name1, "vendor name

    sortl TYPE lfa1-sortl, "search term

    pstlz TYPE lfa1-pstlz, "postal code

    land1 TYPE lfa1-land1, "country

    banks TYPE lfbk-banks,

    bankl TYPE lfbk-bankl, "bank key

    bankn TYPE lfbk-bankn, "account number

    END OF st_vendor.

    TYPES : BEGIN OF st_success,

    lifnr TYPE lfa1-lifnr, "vendor number

    name TYPE lfa1-name1, "vendor name

    END OF st_success.

    TYPES: BEGIN OF st_error,

    linno TYPE i, "line number

    message TYPE string, "error message

    END OF st_error.

    ----


    • INTERNAL TABLE DECLARATIONS

    • WORK AREA DECLARATIONS

    ----


    DATA : it_vendor TYPE STANDARD TABLE OF st_vendor,

    wa_vendor TYPE st_vendor,

    it_success TYPE STANDARD TABLE OF st_success,

    wa_success TYPE st_success,

    it_error TYPE STANDARD TABLE OF st_error,

    wa_error TYPE st_error,

    it_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

    it_message LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

    ----


    • DATA DECLARATION

    ----


    DATA : v_file TYPE string,

    v_tcode(4) VALUE 'XK01',

    v_index LIKE sy-tabix,

    v_totalrec TYPE i,

    v_errrec TYPE i,

    v_succrec TYPE i.

    ----


    • SELECTION SCREEN

    ----


    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    PARAMETERS: p_file TYPE rlgrap-filename.

    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-010.

    PARAMETERS p_mode LIKE ctu_params-dismode DEFAULT 'N' .

    "A: show all dynpros

    "E: show dynpro on error only

    "N: do not display dynpro

    PARAMETERS p_update LIKE ctu_params-updmode DEFAULT 'S'.

    "S: synchronously

    "A: asynchronously

    SELECTION-SCREEN END OF BLOCK b2.

    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-011.

    PARAMETERS : p_group(12) DEFAULT '50871'. "group name for error session

    SELECTION-SCREEN END OF BLOCK b3.

    ----


    • AT SELECTION SCREEN ON VALUE-REQUEST

    ----


    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.

    v_file = p_file.

    *gui upload

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = v_file

    filetype = 'ASC'

    has_field_separator = 'X'

    TABLES

    data_tab = it_vendor

    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.

    *loadind data into it_bdcdata

    LOOP AT it_vendor INTO wa_vendor.

    v_index = sy-tabix.

    PERFORM load_bdcdata.

    ----


    • CALL TRANSACTION

    ----


    CALL TRANSACTION v_tcode USING it_bdcdata

    MODE p_mode

    UPDATE p_update

    MESSAGES INTO it_message.

    *reading success

    IF sy-subrc = 0.

    READ TABLE it_message WITH KEY msgtyp = 'S'.

    IF sy-subrc = 0.

    wa_success-lifnr = it_message-msgv1.

    wa_success-name = wa_vendor-name1.

    APPEND wa_success TO it_success.

    ENDIF.

    ELSE.

    *reading errors

    READ TABLE it_message WITH KEY msgtyp = 'E'.

    IF sy-subrc = 0.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    id = sy-msgid

    no = it_message-msgnr

    v1 = it_message-msgv1

    v2 = it_message-msgv2

    v3 = it_message-msgv3

    v4 = it_message-msgv4

    IMPORTING

    msg = wa_error-message.

    wa_error-linno = v_index.

    APPEND wa_error TO it_error.

    CLEAR wa_error.

    ENDIF.

    *session opening

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    client = sy-mandt

    group = p_group

    holddate = sy-datum

    keep = 'X'

    user = sy-uname.

    *inserting into session

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    tcode = 'XK01'

    TABLES

    dynprotab = it_bdcdata.

    *closing session

    CALL FUNCTION 'BDC_CLOSE_GROUP'.

    ENDIF.

    CLEAR: it_bdcdata, it_message.

    REFRESH: it_bdcdata, it_message.

    ENDLOOP.

    ----


    • SUMMARY DISPLAY

    ----


    DESCRIBE TABLE it_vendor LINES v_totalrec.

    DESCRIBE TABLE it_error LINES v_errrec.

    v_succrec = v_totalrec - v_errrec .

    WRITE : /1 text-004 COLOR 1.

    WRITE : /2 'Total Records Processed :', 25 v_totalrec,

    /2 'Error Records :', 25 v_errrec,

    /2 'Successful Records :', 25 v_succrec.

    SKIP 2.

    WRITE : /1 text-005 COLOR 1.

    LOOP AT it_error INTO wa_error.

    WRITE:/2 wa_error-linno,

    wa_error-message.

    ENDLOOP.

    SKIP 2.

    WRITE : /1 text-009 COLOR 1.

    ULINE AT : /2(46).

    WRITE :/2 sy-vline ,(10) 'VENDOR NUM' , 15 sy-vline , 17 'VENDOR NAME' , 47 sy-vline.

    ULINE AT : /2(46).

    LOOP AT it_success INTO wa_success.

    WRITE:/2 sy-vline , wa_success-lifnr, 15 sy-vline , 17 wa_success-name , 47 sy-vline.

    ENDLOOP.

    ULINE AT : /2(46).

    &----


    *& Form append_bdcdata

    &----


    FORM append_bdcdata USING p_flag p_fname p_fval.

    CLEAR it_bdcdata.

    IF p_flag = 'X'.

    it_bdcdata-program = p_fname.

    it_bdcdata-dynpro = p_fval.

    it_bdcdata-dynbegin = 'X'.

    APPEND it_bdcdata.

    ELSEIF NOT p_fval IS INITIAL.

    it_bdcdata-fnam = p_fname.

    it_bdcdata-fval = p_fval.

    APPEND it_bdcdata.

    ENDIF.

    ENDFORM. "append_bdcdata

    &----


    *& Form load_bdcdata

    &----


    FORM load_bdcdata .

    PERFORM append_bdcdata USING : 'X' 'SAPMF02K' '0100',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'RF02K-KTOKK' wa_vendor-ktokk,

    'X' 'SAPMF02K' '0110',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'LFA1-ANRED' wa_vendor-anred,

    ' ' 'LFA1-NAME1' wa_vendor-name1,

    ' ' 'LFA1-SORTL' wa_vendor-sortl,

    ' ' 'LFA1-PSTLZ' wa_vendor-pstlz,

    ' ' 'LFA1-LAND1' wa_vendor-land1,

    'X' 'SAPMF02K' '0120',

    ' ' 'BDC_OKCODE' '/00',

    'X' 'SAPMF02K' '0130',

    ' ' 'BDC_OKCODE' '=ENTR',

    ' ' 'LFBK-BANKS(01)' wa_vendor-banks,

    ' ' 'LFBK-BANKL(01)' wa_vendor-bankl,

    ' ' 'LFBK-BANKN(01)' wa_vendor-bankn,

    'X' 'SAPMF02K' '0130',

    ' ' 'BDC_OKCODE' '=ENTR',

    'X' 'SAPLSPO1' '0300',

    ' ' 'BDC_OKCODE' '=YES'.

    ENDFORM. " load_bdcdata

    Flat file for this BDC:

    0002 miss nandini n 567845 in in 01 6789954

    0002 mr sandeep s 567760 in in 1000 4355456

    0002 mr pavan p XYZKKK in in 1000 6788996

    0002 MR RAMESH R 345345 IN IN 1000 9867444

    0002 MR 1234 A 111222 IN IN 01 9849813

    0002 MISS RAAGINI R 22222 IN IN 01 5656566

    0002 MR RAM R 333444 IN IN 1000 7887888

    0002 MR RAMS R 888999 IN IN 1000 6576766

    Regards

    Sandeep Reddy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2008 at 04:08 PM

    Hi,

    this depends on the requirement.

    In some cases there may be 2 flat files.

    one for header and second for items

    In some cases there may be 1 flat file.

    2 flat files : one for header and another for item.

    here header is vendor details and items bank details.

    header file

    zsample1 0001 0001 0001 ................

    zsample2 0001 0001 0001 ................

    zsample3 0001 0001 0001 ................

    items file.

    zsample1 DE 100000 name1

    zsample1 DE 100001 name2

    zsample2 DE 100000 name1

    zsample2 DE 100001 name2

    Incase of singlefile details will be as follows:

    zsample1 0001 0001 0001.......DE 100000 name1

    zsample1 0001 0001 0001.......DE 100001 name2

    zsample2 0001 0001 0001 ....DE 100000 name1 .

    zsample2 0001 0001 0001 ... DE 100000 name2

    Just records will be duplicated except at the item values incase of single file.

    Hope this is clear for you.

    Reward points if helpful .

    Thanks and regards

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      HI Ammavajjala Narayana

      Header file

      zsample1 0001 0001 0001 ................

      zsample2 0001 0001 0001 ................

      zsample3 0001 0001 0001 ................

      items file.

      zsample1 DE 100000 name1

      zsample1 DE 100001 name2

      zsample2 DE 100000 name1

      zsample2 DE 100001 name2

      In the above case , each flat file can be made into a seperate

      internal table and the records are matched based on zsample1 or zsample2.

      ****************************************************************

      zsample1 0001 0001 0001.......DE 100000 name1

      zsample1 0001 0001 0001.......DE 100001 name2

      zsample2 0001 0001 0001 ....DE 100000 name1 .

      zsample2 0001 0001 0001 ... DE 100000 name2

      But in case of single flat file as mentioned above

      what is the logic ?

      maximum points will be rewarded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2008 at 04:23 PM

    Hi Diana,

    Below is the flat file for VK11 transaction with fields in order

    KSCHL VKORG VTWG KUNNR MATNR Amount DATAB DATBI

    PR00 0001 01 6 mouse 100.00 20080521 20080522

    PR00 0001 01 6 mouse 200.00 20080521 20080522

    PR00 0001 01 6 mouse 300.00 20080521 20080522

    Reward points if helpful.

    Thanks,

    Khan.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2008 at 04:44 PM

    Hi,

    Incase of single file,

    i have previously mentioned that except the item details all the header details are same for all list items.

    loop at it_xk01.

    at new vendor.

    put header data into work area.

    endat.

    insert item data into workarea (tablecontrol ).

    endloop.

    whenever the new vendor comes then automatically the data changes.

    Hope this is helpful to you.

    Thanks and Regards.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi Ammavajjala Narayana

      I am getting ur point. could u plz provide me with a sample code using this at new concept.

      coz I have a set of perform statements befor and after the line items as shown below.

      at new lifnr

      perform........

      perform........

      perform........

      perform........

      perform........

      end at.

      *for line items

      concetenate...........

      concetenate...........

      concetenate...........

      perform........ " how does this perform statement works

      perform........ " this statements r applicable screens after

      perform........ " the table control

      endloop.

      a sample code using this *at new * concept will solve my issue

      maximum points will be rewarded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 04, 2008 at 05:00 PM

    Hi,

    I am providing code for another scenario i.e condition records.for VK11.

    LOOP AT pi_loadbkt INTO lw_loadbkt.

    tmp_loadbkt = lw_loadbkt.

    AT FIRST.

    PERFORM bdc_dynpro USING 'SAPMV13A' '0100'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ANTA'.

    PERFORM bdc_field USING 'RV13A-KSCHL'

    'YSBC'.

    PERFORM bdc_dynpro USING 'SAPLV14A' '0100'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RV130-SELKZ(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=WEIT'.

    ENDAT.

    AT NEW prodh4.

    PERFORM bdc_dynpro USING 'SAPMV13A' '1734'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'KOMG-KONDA'

    tmp_loadbkt-konda.

    PERFORM bdc_field USING 'KOMG-ZOBKT'

    tmp_loadbkt-zobkt.

    PERFORM bdc_field USING 'KOMG-PRODH1'

    tmp_loadbkt-prodh1.

    PERFORM bdc_field USING 'KOMG-PRODH2'

    tmp_loadbkt-prodh2.

    PERFORM bdc_field USING 'KOMG-PRODH3'

    tmp_loadbkt-prodh3.

    PERFORM bdc_field USING 'KOMG-PRODH4'

    tmp_loadbkt-prodh4.

    ENDAT.

    • Concatenating fieldname

    PERFORM string_concatenate USING 'KOMG-PRODH5(' pv_count ')'

    CHANGING lv_prodh5.

    PERFORM bdc_field USING lv_prodh5

    tmp_loadbkt-prodh5.

    PERFORM string_concatenate USING 'KONP-KBETR(' pv_count ')'

    CHANGING lv_kbetr.

    PERFORM bdc_field USING lv_kbetr

    tmp_loadbkt-kbetr.

    PERFORM string_concatenate USING 'KONP-KONWA(' pv_count ')'

    CHANGING lv_konwa.

    PERFORM bdc_field USING lv_konwa

    tmp_loadbkt-konwa.

    PERFORM string_concatenate USING 'KONP-KPEIN(' pv_count ')'

    CHANGING lv_kpein.

    PERFORM bdc_field USING lv_kpein

    tmp_loadbkt-kpein.

    PERFORM string_concatenate USING 'KONP-KMEIN(' pv_count ')'

    CHANGING lv_kmein.

    PERFORM bdc_field USING lv_kmein

    tmp_loadbkt-kmein.

    CONCATENATE tmp_loadbkt-datab+4(2) '/' "Month

    tmp_loadbkt-datab+6(2) '/' "Date

    tmp_loadbkt-datab+0(4) "Year

    INTO tmp_loadbkt-datab.

    PERFORM string_concatenate USING 'RV13A-DATAB(' pv_count ')'

    CHANGING lv_datab.

    PERFORM bdc_field USING lv_datab

    tmp_loadbkt-datab.

    CONCATENATE tmp_loadbkt-datbi+4(2) '/' "Month

    tmp_loadbkt-datbi+6(2) '/' "Date

    tmp_loadbkt-datbi+0(4) "Year

    INTO tmp_loadbkt-datbi.

    PERFORM string_concatenate USING 'RV13A-DATBI(' pv_count ')'

    CHANGING lv_datbi.

    PERFORM bdc_field USING lv_datbi

    tmp_loadbkt-datbi.

    • To perform vertical scrolling

    PERFORM bdc_dynpro USING 'SAPMV13A' '1734'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=P+'.

    AT END OF prodh4.

    PERFORM bdc_dynpro USING 'SAPMV13A' '1734'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=SICH'.

    IF p_altern = gc_yes.

    PERFORM bdc_insert USING i_bdcdata.

    ELSE.

    • Handling Errors

    PERFORM format_message USING tmp_loadbkt

    i_messtab

    CHANGING pi_loadbkt_error.

    ENDIF.

    REFRESH : i_bdcdata,

    i_messtab.

    ENDAT.

    CLEAR tmp_loadbkt.

    ENDLOOP.

    Thanks and regards.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.