‎2007 Feb 14 4:56 AM
hi abapers,
i have to upload F-02 TCODE through 2 excel sheets.one for header data, and other for line item data. i have to upload the line item records, corresponding to the header records. could any one help me regarding this....thnx in advance..
santosh.
‎2007 Feb 14 4:59 AM
Hi,
It is as same as the normal scenario.
But u define two internal tables one for the header and other for the line items..
Upload the header and line item data into their corresponding tables and then u lop at the header table and then access the line item table to fill the coresponding data..
Hope it is clear..
Cheers,
Simha.
‎2007 Feb 14 5:13 AM
Hi Santosh ,
U can go thru following steps
1. U can use BDC - recording method to simulate F-02 transaction .
2. For this use shdb transaction for recording , and generate source code as per ur transaction F-02 in Program tab of shdb transaction.
3. read data into two separate internal tables using standard FM to read data from excel sheet
4. loop at internal table of header and corresponding pick the value of internal table as per the relation exist between these two excel sheets.
5 Then ur job is done.
I hope this helps
Regards.
Note: Reward if useful
‎2007 Feb 14 5:21 AM
Hi Santhosh,
You need to upload the 2 excel sheets to the 2 internal tables, then loop the header internal table and read the line item internal table then move those to the final internal table and process the BDC.
or, upload the 2 excel sheets into 2 separate internal tables. then
LOOP at ITEM_Internal_table.
Read the header data based on the condition and this should be triggerd only once per record(use the flag)
Process the item data data ... (this is in the loop so it will trigger as many line items are there)(after completing the line item for a record clear the flag, then the next time the header record needs to be process)
read the
Endloop.
Regards
Sudheer
‎2007 Feb 14 7:42 AM
hi sudheer,
i have done just as u told...but we are unable to process it..getting error after completion of first line item...i am sending the source code..pls gor thru once..waiting 4 ur reply...
&----
*& Report ZSAL12
*&
&----
*&
*&
&----
REPORT ZSAL12
&----
*& Report ZSAL11
*&
&----
*&
*&
&----
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
*
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record occurs 0,
x(4) type c,
data element: BLDAT
BLDAT_001(010),
data element: BLART
BLART_002(002),
data element: BUKRS
BUKRS_003(004),
data element: BUDAT
BUDAT_004(010),
data element: MONAT
MONAT_005(002),
data element: WAERS
WAERS_006(005),
data element: KURSF
KURSF_007(012),
data element: XBLNR1
XBLNR_008(016),
data element: BKTXT
BKTXT_009(025),
data element: SAEOBJART
DOCID_010(010),
data element: NEWBS
NEWBS_011(002),
data element: NEWKO
NEWKO_012(017),
data element: WRBTR
WRBTR_013(016),
data element: DZUONR
ZUONR_014(018),
data element: SGTXT
SGTXT_015(050),
data element: FMORE
FMORE_016(001),
data element: KOSTL
KOSTL_017(010),
data element: AUFNR
AUFNR_018(012),
data element: DMBE2
DMBE2_019(016),
data element: NEWBS
NEWBS_020(002),
data element: NEWKO
NEWKO_021(017),
data element: WRBTR
WRBTR_022(016),
data element: VALUT
VALUT_023(010),
data element: DZUONR
ZUONR_024(018),
data element: SGTXT
SGTXT_025(050),
data element: FMORE
FMORE_026(001),
end of record.
*
data: begin of record1 occurs 0,
y(4) type c,
data element: BLDAT
BLDAT_001(010),
data element: BLART
BLART_002(002),
data element: BUKRS
BUKRS_003(004),
data element: BUDAT
BUDAT_004(010),
data element: MONAT
MONAT_005(002),
data element: WAERS
WAERS_006(005),
data element: KURSF
KURSF_007(012),
data element: XBLNR1
XBLNR_008(016),
data element: BKTXT
BKTXT_009(025),
data element: SAEOBJART
DOCID_010(010),
data element: NEWBS
NEWBS_011(002),
data element: NEWKO
NEWKO_012(017),
data element: WRBTR
WRBTR_013(016),
data element: DZUONR
ZUONR_014(018),
data element: SGTXT
SGTXT_015(050),
data element: FMORE
FMORE_016(001),
data element: KOSTL
KOSTL_017(010),
data element: AUFNR
AUFNR_018(012),
data element: DMBE2
DMBE2_019(016),
data element: NEWBS
NEWBS_020(002),
data element: NEWKO
NEWKO_021(017),
data element: WRBTR
WRBTR_022(016),
data element: VALUT
VALUT_023(010),
data element: DZUONR
ZUONR_024(018),
data element: SGTXT
SGTXT_025(050),
data element: NEWBS
NEWBS_026(02),
data element: NEWKO
NEWKO_027(017),
*
data element: FMORE
FMORE_026(001),
end of record1.
End generated data section ***
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ''
FILETYPE = 'DAT'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = record
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ' '
FILETYPE = 'DAT'
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = RECORD1
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*perform open_dataset using dataset.
perform open_group.
loop at record1.
loop at record where x = record1-y.
*read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
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'
record-BLDAT_001.
perform bdc_field using 'BKPF-BLART'
record-BLART_002.
perform bdc_field using 'BKPF-BUKRS'
record-BUKRS_003.
perform bdc_field using 'BKPF-BUDAT'
record-BUDAT_004.
perform bdc_field using 'BKPF-MONAT'
record-MONAT_005.
perform bdc_field using 'BKPF-WAERS'
record-WAERS_006.
perform bdc_field using 'BKPF-KURSF'
record-KURSF_007.
perform bdc_field using 'BKPF-XBLNR'
record-XBLNR_008.
perform bdc_field using 'BKPF-BKTXT'
record-BKTXT_009.
*perform bdc_field using 'FS006-DOCID'
record-DOCID_010.
*loop at record1 where y = record-x.
*append record.
endloop.
perform bdc_field using 'RF05A-NEWBS'
record1-NEWBS_011.
perform bdc_field using 'RF05A-NEWKO'
record1-NEWKO_012.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=ZK'.
perform bdc_field using 'BSEG-WRBTR'
record1-WRBTR_013.
perform bdc_field using 'BSEG-ZUONR'
record1-ZUONR_014.
perform bdc_field using 'BSEG-SGTXT'
record1-SGTXT_015.
*perform bdc_field using 'DKACB-FMORE'
record-FMORE_016.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-AUFNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
record1-KOSTL_017.
perform bdc_field using 'COBL-AUFNR'
record1-AUFNR_018.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_CURSOR'
'10/21'.
perform bdc_field using 'BDC_OKCODE'
'=PICK'.
perform bdc_dynpro using 'SAPMF05A' '0330'.
perform bdc_field using 'BDC_CURSOR'
'RF05A-NEWKO'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BSEG-DMBE2'
record1-DMBE2_019.
perform bdc_field using 'RF05A-NEWBS'
record1-NEWBS_020.
perform bdc_field using 'RF05A-NEWKO'
record1-NEWKO_021.
perform bdc_field using 'BDC_OKCODE'
'=PICK'.
perform bdc_dynpro using 'SAPMF05A' '0300'.
perform bdc_field using 'BDC_CURSOR'
'BSEG-SGTXT'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BSEG-WRBTR'
record1-WRBTR_022.
*perform bdc_field using 'BSEG-VALUT'
record-VALUT_023.
perform bdc_field using 'BSEG-ZUONR'
record1-ZUONR_024.
perform bdc_field using 'BSEG-SGTXT'
record1-SGTXT_025.
*append record1.
*perform bdc_field using 'DKACB-FMORE'
record-FMORE_026.
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 'RF05A-NEWBS'
record1-NEWBS_026.
perform bdc_field using 'RF05A-NEWKO'
record1-NEWKO_027.
perform bdc_transaction using 'F-02'.
*endloop.
endloop.
perform close_group.
*perform close_dataset using dataset.
‎2007 Feb 14 7:54 AM
Hi,
Just follow these steps when you are writing the code ...
Loop at Itam_table.
if flag is initial.
read table for header (This will have only one record so read table is enough).
process the Header.
endif. (For flag)
flag = 'X'.
Process the line items. (Please maintain the correct screen no and the Ok Codes)
endloop.
based on the Link betweem header and item record, you need to clear the flag, so that the next record comes then the header record shoulb be process.
Regards
Sudheer