Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BSEG table?

Former Member
0 Likes
3,064

Hi Guys,

I want to download the data from BSEG table.I wrote a pgm for downloading the whole data into Spread sheet ,but i am getting only 267 columns and downloaded manually in which i am getting only 100 columns.Can anyone tell me what's the best way to get all the Columns.

Thanks,

Gopi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,950

Try with this -:)

<a href="/people/alvaro.tejadagalindo/blog/2006/03/16/taking-good-care-of-z-data good care of Z Data</a>

Greeetings,

Blag.

12 REPLIES 12
Read only

Former Member
0 Likes
2,951

Try with this -:)

<a href="/people/alvaro.tejadagalindo/blog/2006/03/16/taking-good-care-of-z-data good care of Z Data</a>

Greeetings,

Blag.

Read only

Former Member
0 Likes
2,950

Hi Gopi,

I don't think there is a way through which we can get all the BSEG data directly in the file on presentation server.

What I did was, written a small program which can download the data onto application server in text file, which later on can be used to convert in excel file. You can also try the same thing. It is much easier.

Reward points if useful.

Regards,

Atish

Read only

0 Likes
2,950

Hi Atish,

Thanks for ur reponse,Can u send me the program how to write using BSEG table and write into application server.

ThanGopi.

Read only

0 Likes
2,950

Hi Atish,

Thanks for ur reponse,Can u send me the program how to write using BSEG table and write into application server.

Thanks,

Gopi

Read only

0 Likes
2,950

Hi Gopi,

Below is the code. Change for yourself.

Do reward points to helpful answers.

REPORT ZFI_DOWNLOAD_BKPF_BSEG.

  • This program is used to download the data from BKPF and BSEG table

  • to the application server as there is huge amount of data and it can't

  • be downloaded on local machine (length restriction of 1023 char only)

TABLES: BKPF,

BSEG.

DATA I_BKPF TYPE TABLE OF BKPF WITH HEADER LINE.

*DATA i_bseg TYPE TABLE OF bseg WITH HEADER LINE.

DATA: BEGIN OF I_BSEG OCCURS 0,

BUKRS TYPE BSEG-BUKRS,

BELNR TYPE BSEG-BELNR,

GJAHR TYPE BSEG-GJAHR,

BUZEI TYPE BSEG-BUZEI,

BUZID TYPE BSEG-BUZID,

AUGDT TYPE BSEG-AUGDT,

AUGCP TYPE BSEG-AUGCP,

AUGBL TYPE BSEG-AUGBL,

BSCHL TYPE BSEG-BSCHL,

KOART TYPE BSEG-KOART,

UMSKZ TYPE BSEG-UMSKZ,

UMSKS TYPE BSEG-UMSKS,

ZUMSK TYPE BSEG-ZUMSK,

SHKZG TYPE BSEG-SHKZG,

MWSKZ TYPE BSEG-MWSKZ,

DMBTR TYPE CHAR16,

WRBTR TYPE CHAR16,

PSWBT TYPE CHAR16,

PSWSL TYPE BSEG-PSWSL,

MWSTS TYPE CHAR16,

WMWST TYPE CHAR16,

FWBAS TYPE CHAR16,

HWZUZ TYPE CHAR16,

SHZUZ TYPE BSEG-SHZUZ,

MWART TYPE BSEG-MWART,

KTOSL TYPE BSEG-KTOSL,

SGTXT TYPE BSEG-SGTXT,

FDWBT TYPE CHAR18,

FKONT TYPE BSEG-FKONT,

KOKRS TYPE BSEG-KOKRS,

KOSTL TYPE BSEG-KOSTL,

PERNR TYPE BSEG-PERNR,

XHRES TYPE BSEG-XHRES,

XINVE TYPE BSEG-XINVE,

XAUTO TYPE BSEG-XAUTO,

SAKNR TYPE BSEG-SAKNR,

HKONT TYPE BSEG-HKONT,

KUNNR TYPE BSEG-KUNNR,

LIFNR TYPE BSEG-LIFNR,

XBILK TYPE BSEG-XBILK,

GVTYP TYPE BSEG-GVTYP,

HZUON TYPE BSEG-HZUON,

ZTERM TYPE BSEG-ZTERM,

ZBD1T TYPE BSEG-ZBD1T,

ZBD2T TYPE BSEG-ZBD2T,

ZBD3T TYPE BSEG-ZBD3T,

ZBD1P TYPE BSEG-ZBD1P,

ZBD2P TYPE BSEG-ZBD2P,

SKFBT TYPE CHAR16,

SKNTO TYPE CHAR16,

WSKTO TYPE CHAR16,

ZLSCH TYPE BSEG-ZLSCH,

ZBFIX TYPE BSEG-ZBFIX,

DMBT1 TYPE CHAR18,

REBZJ TYPE BSEG-REBZJ,

REBZZ TYPE BSEG-REBZZ,

KLIBT TYPE CHAR16,

ZEKKN TYPE BSEG-ZEKKN,

PEINH TYPE BSEG-PEINH,

REWRT TYPE CHAR18,

TBTKZ TYPE BSEG-TBTKZ,

SPGRQ TYPE BSEG-SPGRQ,

PRCTR TYPE BSEG-PRCTR,

XHKOM TYPE BSEG-XHKOM,

KSTRG TYPE BSEG-KSTRG,

BTYPE TYPE BSEG-BTYPE,

LNRAN TYPE BSEG-LNRAN,

XRAGL TYPE BSEG-XRAGL,

LOKKT TYPE BSEG-LOKKT,

FISTL TYPE BSEG-FISTL,

STBUK TYPE BSEG-STBUK,

FKBER TYPE BSEG-FKBER,

DTWS1 TYPE BSEG-DTWS1,

DTWS2 TYPE BSEG-DTWS2,

DTWS3 TYPE BSEG-DTWS3,

DTWS4 TYPE BSEG-DTWS4,

AGZEI TYPE BSEG-AGZEI,

PYAMT TYPE CHAR16,

END OF I_BSEG.

DATA: BEGIN OF I_BKPF_SEL OCCURS 0,

BUKRS TYPE BKPF-BUKRS,

BELNR TYPE BKPF-BELNR,

GJAHR TYPE BKPF-GJAHR,

END OF I_BKPF_SEL.

DATA: IOUT TYPE TABLE OF STRING.

DATA: XOUT TYPE STRING.

FIELD-SYMBOLS: <FS>.

  • Tab delimiter

DATA: C_TAB TYPE X VALUE '09',

C_LFEED TYPE X VALUE '0A'.

SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME TITLE TEXT-001 .

PARAMETERS: P_BKPF RADIOBUTTON GROUP ORAD,

P_BSEG RADIOBUTTON GROUP ORAD.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY,

P_BUKRS LIKE BKPF-BUKRS OBLIGATORY.

SELECT-OPTIONS: SO_BELNR FOR BKPF-BELNR,

SO_MONAT FOR BKPF-MONAT NO INTERVALS .

PARAMETERS: P_GJAHR LIKE BKPF-GJAHR OBLIGATORY.

SELECTION-SCREEN END OF BLOCK SELECTION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM F4_FOR_FILENAME CHANGING P_FILE.

START-OF-SELECTION.

REFRESH IOUT[].

CLEAR XOUT.

IF P_BKPF = 'X'.

SELECT * FROM BKPF INTO TABLE I_BKPF

WHERE BUKRS = P_BUKRS

AND BELNR IN SO_BELNR

AND GJAHR = P_GJAHR

AND MONAT IN SO_MONAT.

IF SY-SUBRC NE 0.

MESSAGE S000(SU) WITH 'No Data found for given selection'.

LEAVE LIST-PROCESSING.

ENDIF.

ELSE.

SELECT * FROM BKPF INTO CORRESPONDING FIELDS OF TABLE I_BKPF_SEL

WHERE BUKRS = P_BUKRS

AND BELNR IN SO_BELNR

AND GJAHR = P_GJAHR

AND MONAT IN SO_MONAT.

IF NOT I_BKPF_SEL[] IS INITIAL.

SELECT * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE I_BSEG

FOR ALL ENTRIES IN I_BKPF_SEL

WHERE BUKRS = I_BKPF_SEL-BUKRS

AND BELNR = I_BKPF_SEL-BELNR

AND GJAHR = I_BKPF_SEL-GJAHR.

ENDIF.

  • SELECT * FROM bseg INTO CORRESPONDING FIELDS OF TABLE i_bseg

  • WHERE bukrs = p_bukrs

  • AND belnr IN so_belnr

  • AND gjahr = p_gjahr.

IF SY-SUBRC NE 0.

MESSAGE S000(SU) WITH 'No Data found for given selection'.

LEAVE LIST-PROCESSING.

ENDIF.

ENDIF.

END-OF-SELECTION.

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.

IF P_BKPF = 'X'.

    • BKPF Column headings

  • IF NOT I_BKPF[] IS INITIAL.

  • PERFORM BKPF_COLUMN_HEADINGS USING XOUT.

  • CONCATENATE XOUT C_LFEED INTO XOUT.

  • APPEND XOUT TO IOUT.

  • ENDIF.

LOOP AT I_BKPF.

DO.

ASSIGN COMPONENT SY-INDEX OF STRUCTURE I_BKPF TO <FS>.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

IF SY-INDEX = 1.

XOUT = <FS>.

ELSE.

IF NOT <FS> IS INITIAL.

CONCATENATE XOUT <FS> INTO XOUT SEPARATED BY C_TAB.

ELSE.

CONCATENATE XOUT SPACE INTO XOUT SEPARATED BY C_TAB.

ENDIF.

ENDIF.

ENDDO.

  • Line feed

  • CONCATENATE xout c_lfeed INTO xout.

APPEND XOUT TO IOUT.

CLEAR XOUT.

ENDLOOP.

ELSE.

    • BSEG line headings

  • IF NOT I_BSEG[] IS INITIAL.

  • PERFORM BSEG_COLUMN_HEADINGS USING XOUT.

  • CONCATENATE XOUT C_LFEED INTO XOUT.

  • APPEND XOUT TO IOUT.

  • ENDIF.

LOOP AT I_BSEG.

DO.

ASSIGN COMPONENT SY-INDEX OF STRUCTURE I_BSEG TO <FS>.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

IF SY-INDEX = 1.

XOUT = <FS>.

ELSE.

IF NOT <FS> IS INITIAL.

CONCATENATE XOUT <FS> INTO XOUT SEPARATED BY C_TAB.

ELSE.

CONCATENATE XOUT SPACE INTO XOUT SEPARATED BY C_TAB.

ENDIF.

ENDIF.

ENDDO.

  • Line feed

  • CONCATENATE xout c_lfeed INTO xout.

APPEND XOUT TO IOUT.

CLEAR XOUT.

ENDLOOP.

ENDIF.

LOOP AT IOUT INTO XOUT.

TRANSFER XOUT TO P_FILE.

ENDLOOP.

CLOSE DATASET P_FILE.

----


  • FORM F4_FOR_FILENAME *

----


  • ........ *

----


FORM F4_FOR_FILENAME CHANGING P_FILE.

DATA LV_FULLPATH TYPE TEXT452.

CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'

EXPORTING

  • directory = fp_directory

FILEMASK = '.'

IMPORTING

SERVERFILE = LV_FULLPATH

EXCEPTIONS

CANCELED_BY_USER = 1

OTHERS = 2.

IF SY-SUBRC EQ 1 OR LV_FULLPATH IS INITIAL.

  • SET CURSOR FIELD fp_fname.

MESSAGE S000(SU)

WITH 'Unexpected Error.'. "#EC NOTEXT

LEAVE LIST-PROCESSING.

ELSE.

P_FILE = LV_FULLPATH.

ENDIF.

ENDFORM.

&----


*& Form BKPF_COLUMN_HEADINGS

&----


FORM BKPF_COLUMN_HEADINGS USING P_OUT.

CLEAR P_OUT.

CONCATENATE

'Client'

'Company code'

'Accounting document number'

'Fiscal year'

'Document type'

'Document date in document'

'Posting date in the document'

'Fiscal period'

'Accounting document entry date'

'Time of entry'

'Date of the last document change'

'Date of the last document update'

'Translation date'

'User name'

'Transaction code'

'Number of the cross-company code transaction'

'Reference document number'

'Recurring entry document number'

'Reverse document number'

'Reverse document fiscal year'

'Document header text'

'Currency key'

'Exchange rate'

'Currency key for the group currency'

'Group currency exchange rate'

'Document status'

'Indicator: Document posted net ?'

'Unplanned delivery costs'

'Indicator: Document is posted to a previous period'

'Business transaction'

'Batch input session name'

'Document name in the archive system'

'Extract ID document header'

'Internal document type for document control'

'Reference procedure'

'Object key'

'Financial management area'

'Local currency'

'Currency key of second local currency'

'Currency key of third local currency'

'Exchange rate for the second local currency'

'Exchange rate for the third local currency'

'Source currency for the currency translation'

'Source currency for the currency translation'

'Translation date type for second local currency'

'Translation date type for third local currency'

'Indicator: Document is flagged for reversal'

'Planned date for the reverse posting'

'Indicator: Tax calculated automatically'

'Currency type of second local currency'

'Currency type of third local currency'

'Exchange rate type'

'Exchange rate type'

'G/L account amounts entered exclude tax'

'Source company code'

'Indicator: US taxes changed at detail level ?'

'Status of data transfer into subsequent release'

'Logical system'

'Exchange rate for taxes'

'Lot number for funds reservations'

'Indicator: Customer bill of exchange payment before due date'

'Reason for reversal'

'Name of user who parked this document'

'Branch number'

'Number of pages of invoice'

'Indicator: entry represents a discount document'

INTO P_OUT SEPARATED BY C_TAB.

ENDFORM. " BKPF_COLUMN_HEADINGS

&----


*& Form BSEG_COLUMN_HEADINGS

&----


FORM BSEG_COLUMN_HEADINGS USING P_OUT.

CLEAR P_OUT.

CONCATENATE

'Client'

'Clearing item'

'Document number of the clearing document'

'Clearing entry date'

'Clearing date'

'Accounting document number'

'Posting key'

'Billing indicator'

'Company code'

'Line item number within the accounting document'

'Identification of the line item'

'Amount in local currency for tax distribution'

'Amount in local currency'

'Instruction key 1'

'Instruction key 2'

'Instruction key 3'

'Instruction key 4'

'Planning amount in document currency'

'Funds center'

'Functional area'

'Financial budget item'

'Tax base amount in document currency'

'Fiscal year'

'P+l statement account type'

'General ledger account'

'Provision amount in local currency'

'Allocation number for special g/l accounts'

'Credit control amount'

'Account type'

'Controlling area'

'Cost center'

'Cost object'

'Transaction key'

'Customer number'

'Account number of the vendor or creditor'

'Sequence number of asset line items in fiscal year'

'Alternative account number in company code'

'Tax type'

'Tax code'

'Tax amount in local currency'

'Price unit'

'Personnel number'

'Profit center'

'Amount for updating in general ledger'

'Update currency for general ledger transaction figures'

'Amount in payment currency'

'Fiscal year of the relevant invoice (in credit memo)'

'Line item in the relevant invoice'

'Invoice value entered (in local currency)'

'G/l account number'

'Item text'

'Debit/credit indicator'

'Debit/credit addition for cash discount'

'Amount eligible for cash discount in document currency'

'Cash discount amount in local currency'

'Indicator: manual blocking reason'

'Tax company code'

'Indicator: subsequent debit/credit'

'Special g/l transaction type'

'Special g/l indicator'

'Tax amount in document currency'

'Amount in document currency'

'Cash discount amount in document currency'

'Indicator: line item automatically created'

'Indicator: account is a balance sheet account?'

'Indicator: g/l account assigned manually ?'

'Indicator: resident g/l account ?'

'Indicator: capital goods affected?'

'Indicator: clearing was reversed'

'Percentage for first cash discount'

'Days for first cash discount'

'Percentage for second cash discount'

'Days for second cash discount'

'Net payment terms period'

'Fixed payment terms'

'Serial number of account assignment'

'Payment method'

'Terms of payment key'

'Target special g/l indicator'

INTO P_OUT SEPARATED BY C_TAB.

ENDFORM. " BSEG_COLUMN_HEADINGS

Regards,

Atish

Read only

0 Likes
2,950

Hi Atish,

I tried like what u said.I wrote the code but i am getting error at "transfer" command like file not found .I am sending u the code

if rb_bgrnd = 'X'.

  • wa_BSEG_file = '/interfaces/DR1/TM/inbound/ZHRIF0010/work/bseg.xls' .

CONCATENATE:'/interfaces/' sy-sysid

'/TM/inbound/ZHRIF0010/work/bseg.xls' INTO wa_BSEG_file.

endif.

select * into table it_bseg from BSEG up to 1000 rows .

OPEN DATASET wa_BSEG_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

LOOP at IT_BSEG into WA_BSEG.

TRANSFER WA_BSEG to wa_BSEG_file.

ENDLOOP.

Write : 'File Transferred BSEG'.

ELSE .

Write : 'File Not Found / Transferred BSEG'.

ENDIF.

CLOSE DATASET wa_BSEG_file.

Can u tell me how to store in the Application server .I mean path .there only i am geting problem.Can u correct that part .

Thanks,

Gopi.

Read only

0 Likes
2,950

Hi Gopi,

While transfering data to the application server you can not use .xls file.

You have to use .txt file.

Cahnge the code as below and try.

CONCATENATE:'/interfaces/' sy-sysid

'/TM/inbound/ZHRIF0010/work/bseg.<b>txt</b>' INTO wa_BSEG_file.

endif.

Reward points to all useful answers.

Regards,

Atish

Read only

0 Likes
2,950

Hi Atish,

I tried like what u said.I am sending u the code.

if rb_bgrnd = 'X'.

  • wa_BSEG_file = '/interfaces/DR1/TM/inbound/ZHRIF0010/work/bseg.xls' .

CONCATENATE:'/interfaces/' sy-sysid

'/TM/inbound/ZHRIF0010/work/bseg.xls' INTO wa_BSEG_file.

endif.

select * into table it_bseg from BSEG up to 1000 rows .

OPEN DATASET wa_BSEG_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

LOOP at IT_BSEG into WA_BSEG.

TRANSFER WA_BSEG to wa_BSEG_file.

ENDLOOP.

Write : 'File Transferred BSEG'.

ELSE .

Write : 'File Not Found / Transferred BSEG'.

ENDIF.

CLOSE DATASET wa_BSEG_file.

Can u correct if i have to make the changes.

Thanks,

Gopi.

Read only

0 Likes
2,950

Hi Atish,

I tried like what u said,but i am getting errors at transfer command.I am pasting the code what i wrote.

if rb_bgrnd = 'X'.

  • wa_BSEG_file = '/interfaces/DR1/TM/inbound/ZHRIF0010/work/bseg.xls' .

CONCATENATE:'/interfaces/' sy-sysid

'/TM/inbound/ZHRIF0010/work/bseg.xls' INTO wa_BSEG_file.

endif.

select * into table it_bseg from BSEG up to 1000 rows .

OPEN DATASET wa_BSEG_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

LOOP at IT_BSEG into WA_BSEG.

TRANSFER WA_BSEG to wa_BSEG_file.

ENDLOOP.

Write : 'File Transferred BSEG'.

ELSE .

Write : 'File Not Found / Transferred BSEG'.

ENDIF.

CLOSE DATASET wa_BSEG_file.

can u plz correct the code if ther r any changes required.

Thanks,

Gopi.

Read only

0 Likes
2,950

Hello Gopi,

if rb_bgrnd = 'X'.

  • wa_BSEG_file = '/interfaces/DR1/TM/inbound/ZHRIF0010/work/bseg.xls' .

CONCATENATE:'/interfaces/' sy-sysid

'/TM/inbound/ZHRIF0010/work/bseg.<b>txt</b>' INTO wa_BSEG_file.

endif.

select * into table it_bseg from BSEG up to 1000 rows .

OPEN DATASET wa_BSEG_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

LOOP at IT_BSEG into WA_BSEG.

TRANSFER WA_BSEG to wa_BSEG_file.

ENDLOOP.

Write : 'File Transferred BSEG'.

ELSE .

Write : 'File Not Found / Transferred BSEG'.

ENDIF.

CLOSE DATASET wa_BSEG_file.

see the results now

Read only

0 Likes
2,950

Instead of transfer you can as well use Read dataset.

OPEN DATASET wa_BSEG_file FOR OUTPUT "Write to appl. server

IN TEXT MODE

ENCODING DEFAULT. "Open dataset Return code

IF sy-subrc = 0.

do.

read dataset wa_BSEG_file into <dobj>

enddo.

<dobj> can be any dataobject or infact a string too.

Read only

0 Likes
2,950

Hi Gopi,

Is this issue resolved or you still facing problem.

Close the thread if it is resolved.

Regards,

Atish