Accessing huge tables like bseg, bkpf
1) What are the precautions we should consider while accessing huge tables like bseg, bkpf or mseg tables.
Hi,
Some tips may be:
1)
Write the Select statements covering all( or almost all ) the primary keys in the same order as defined in the DB table in the WHERE clause.
2)
Incase, if you were using the fields that were not in the Primary key of the DB table, create Secondary indexes on these fields.
3)
Always try using an Array fetch of the records on the table instead of going for Select & Endselect....
Thanks,
Vishnu.
Similar Messages
-
Is there any other table like BSEG with same fields.
Hi Abapers,
I want to use BSEG table.But due to some promblem BSEG table is not supporting.So is there any other table like BSEG with same fields.
can any one help me.
with regardsSince performance may be an issue when hitting BSEG table
Any of the below accounting tables can be used.
1.BSAD
2.BSAK
3.BSAS
4.BSID
5.BSIK
6.BSIS
These are normal database tables, not clusters. Normally every record from BSEG can be found in one of these 6 tables. The program which selects data
From these tables runs faster than from BSEG.
Plz reward if helpful.
Thanks.
Ramya -
Missing table entries: BSEG
hie gurus
after altering a field structure for BSEG i have noticed that some transactions went missing however i was able to get some of them from tables BKPF(document header) BSIS(2ndry index for G/L accounts) and BSAS(2ndry index for cleared items). however wen i populate the entries from bsis that are not in bseg on documnet display if i double click i cannot get the original document? i have missed sokme information that needs to populated also in bseg but im not sure where to get it.
please assist.
PrinceHi
Due to the nature of the change required on the table BSEG it meant taking the risk of losing/corrupting data. The former occured and i would advise against making structural changes to field/table definitions on critical tables like BSEG.
regards
Isaac Prince -
Gurus,
I have to write the logic to fetch data from bkpf and bseg. Need help on how can i do that..
I have to get bukrs belnr gjahr ldgrp from BKPF for a given date and company code. For all these documents, then i have to get the line items from BSEG if the ldgrp is I1 or SPACE.
If the ldgrp is not I1 or SPACE then i have to fetch the records from BSEG_ADD and then generate a ALV report with all the data including the data that was fetched from BKPF.
So, it wil be a combined ALV report that displays header as well as LINE item data together...
Can u please help me with the code...I am not sure how can everything go all together in one internal table....Becoz once its there in one table then only a ALV list can be generated.......
Cheers:
Samhi Sam, this may be of some similar thing.
Use this program, I got this prog from a source and we added a small conditional check in the program which checks document numbers in BSEG and also comapres in BKPF and sees if the output from BSEG falls under the posting data range specified in the initial selection.
Now just so you know, this output is kinda messed up, so you will have to play with it in Excel to extract the document numbers, if that is what you want.
============================
PROGRAM....... ZFI_BSEG_DOWNLOAD
TITLE......... Download BSEG
PROGRAM TYPE.. Download
======================================================================
GENERAL DOCUMENTATION AND COMMENTS
<...>
======================================================================
ASSOCIATED PROGRAMS
<Program>..... <Description>
======================================================================
CHANGE HISTORY
Date By Ticket Description
REPORT zfi_bseg_download.
TABLES: bseg, bkpf.
TYPES: BEGIN OF ty_output,
line(6000) TYPE c,
END OF ty_output.
TYPES: ty_tab_output TYPE TABLE OF ty_output,
ty_tab_nametab TYPE TABLE OF x031l.
CONSTANTS: c_delimiter(04) TYPE c VALUE '"%%"',
c_records TYPE i VALUE 10000.
SELECTION-SCREEN
SELECT-OPTIONS: p_bukrs FOR bseg-bukrs,
p_belnr FOR bseg-belnr,
p_buzei FOR bseg-buzei,
p_gjahr FOR bseg-gjahr,
p_budat for bkpf-budat.
SELECTION-SCREEN SKIP.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: p_append AS CHECKBOX DEFAULT 'X'.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_records.
*& Form get_records
FORM get_records.
DATA: l_cursor TYPE cursor,
lt_bseg TYPE TABLE OF bseg,
ls_bseg LIKE LINE OF lt_bseg,
lt_output TYPE ty_tab_output,
ls_output LIKE LINE OF lt_output,
lt_nametab TYPE ty_tab_nametab,
ls_nametab LIKE LINE OF lt_nametab,
l_field(30) TYPE c,
l_output(50) TYPE c,
l_date(10) TYPE c,
l_len TYPE i.
FIELD-SYMBOLS: <field>.
IF p_append NE space.
OPEN DATASET p_file FOR APPENDING IN TEXT MODE.
ELSE.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.
ENDIF.
Retrieve BSEF fieldnames and data types
PERFORM get_fields CHANGING lt_nametab.
OPEN CURSOR l_cursor FOR
SELECT * FROM bseg
WHERE bukrs IN p_bukrs
AND belnr IN p_belnr
AND buzei IN p_buzei
AND gjahr IN p_gjahr.
Write out fieldnames
IF p_append IS INITIAL.
LOOP AT lt_nametab INTO ls_nametab.
CONCATENATE ls_output ls_nametab-fieldname
INTO ls_output SEPARATED BY c_delimiter.
ENDLOOP.
IF ls_output+0(4) = c_delimiter.
SHIFT ls_output LEFT BY 4 PLACES.
ENDIF.
l_len = strlen( ls_output ).
TRANSFER ls_output TO p_file LENGTH l_len.
ENDIF.
Process BSEG records
DO.
CLEAR lt_bseg.
FETCH NEXT CURSOR l_cursor
INTO TABLE lt_bseg
PACKAGE SIZE c_records.
IF sy-subrc 0.
EXIT.
ENDIF.
LOOP AT lt_bseg INTO ls_bseg.
SELECT single * FROM BKPF
WHERE BUKRS = ls_bseg-BUKRS
AND BELNR = ls_bseg-BELNR
AND GJAHR = ls_bseg-GJAHR
AND BUDAT in p_budat.
if syst-subrc 0.
continue.
endif.
CLEAR ls_output.
Process individual fields of BSEG record
LOOP AT lt_nametab INTO ls_nametab.
CONCATENATE 'LS_BSEG-' ls_nametab-fieldname INTO l_field.
ASSIGN (l_field) TO <field>.
CLEAR l_output.
Process by field data types
CASE ls_nametab-exid.
WHEN 'C' OR 'N' OR 'I'.
Character, Numeric & Integer
l_output = <field>.
WHEN 'D'.
Dates
WRITE <field> TO l_date DD/MM/YYYY.
l_output = l_date.
WHEN 'P'.
Packed decimals
WRITE <field> TO l_output.
WHEN OTHERS.
MESSAGE a000(zs) WITH 'Data type error - ' ls_nametab-exid.
ENDCASE.
SHIFT l_output LEFT DELETING LEADING space.
CONCATENATE ls_output l_output
INTO ls_output SEPARATED BY c_delimiter.
ENDLOOP.
IF ls_output+0(4) = c_delimiter.
SHIFT ls_output LEFT BY 4 PLACES.
ENDIF.
l_len = strlen( ls_output ).
TRANSFER ls_output TO p_file LENGTH l_len.
ENDLOOP.
IF sy-subrc = 0.
ENDIF.
ENDDO.
CLOSE CURSOR l_cursor.
CLOSE DATASET p_file.
ENDFORM. " get_records
*& Form get_fields
FORM get_fields CHANGING pt_nametab TYPE ty_tab_nametab.
CALL FUNCTION 'RFC_GET_NAMETAB'
EXPORTING
tabname = 'BSEG'
TABLES
nametab = pt_nametab
EXCEPTIONS
table_not_active = 1
OTHERS = 2.
IF sy-subrc 0.
ENDIF.
ENDFORM. " get_fields
hope this helps.
cheers,
Hema. -
Extension for MIRO to update BSEG/BKPF
Hi Experts,
When MIRO transaction is saved, an user-exit should be triggered to update the 3 fields like ESRNR,ESRRE & ZLSPR(which is stored in structure RBKP_V).
I tried all the 7 user exits (LMR1M001,LMR1M002, LMR1M003, LMR1M004, LMR1M005, LMR1M006, RMVKON00 , MRMH0001, MRMH0002 ,MRMH0003, MRMN0001) and 1 badi (INVOICE_UPDATE) .But in all this the structure RBKP_V is an importing parameter except LMR1M006 .But this user-exit is not getting triggered because it is change XML data.
Now what I am looking is , to update the 3 fields in tables BKPF or BSEG. Because when a MIRO is saved , 2 document number is created (1 in Accounting document and the other in Invoice document ).
So is there any user-exit or BADI to update BSEG /BKPF in transaction MIRO.
Kindly help me
It is very urgent.
Thanks in advance
Points will be rewarded.Hi Vinod,
This can be done through FI Substitution, you may need to write an Exit in FI Substitution. Talk to your FI Consultants, and they should help you.
Regards
Srikanth M -
Accessing internal tables at runtime.
Hi all,
I am writing a code where in i have to transfer data from excel to database table.
Iam getting the excel data in an itab. Can anybody help me with how to access internal tables at runtime ?
i am using the following code with sy-tabix. here, when the sy-tabix is odd it picks up the value,
but i want that within the same loop when i increment sy-tabix by 1, then it should fetch the second column of same row. But its not working as it shows an error that it does not permit subfield access.
the code is as follows:
LOOP AT t_tab[] into wa_tab .
data: l_tabix type sy-tabix,
name_index type sy-tabix.
data: c type i.
l_tabix = sy-tabix.
name_index = l_tabix+1.
c = ( l_tabix mod 2 ).
******to check if sy-tabix is odd**********
if c ne 0.
READ TABLE t_tab into wa_tab index l_tabix.
wa_product1-product = wa_tab-VALUE.
************incrementing sy-tabix*************
READ TABLE t_tab into wa_tab index name_index. (here it shows error)
wa_product1-product_name = wa_tab-value.
endif.
endloop.
Thanks in advance.Hi Omer,
Copy and paste this code.
=====================================
REPORT ztest_create_data_dynamic .
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
Build fieldcat
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SYST'
CHANGING
ct_fieldcat = it_fcat[].
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
MOVE-CORRESPONDING is_fcat TO is_fieldcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = sy-index.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
WRITE <l_field>.
ENDLOOP. -
Error while accessing BSAD Table with dunning date
Hi ,
I developed a report for FI module accessing BSAD table with default customer ranges and for specific dunning dates - It ran for a very long time and timed out - (I know this is due to huge volume of data) -
Is there any way to access BSAD table easily with Dunning dates (Other than creating Index on it) ???
Or any standard function module available ??
Regards
Rajesh.Hi
Try the below tables for the dunning data details:
MHND Dunning Data
MHNDO Dunning data version before the next change
MHNK Dunning data (account entries)
MHNKA Version administration of dunning changes
MHNKO Dunning data (acct entries) version before the next chang
SKS -
dear all,
i have done a system copy from production server into quality server. quality was scrapped and freshly installed with SAP then used the DB flush method to carry out the system copy. i had to change the DBS_ORA_SCHEMA in environment variables to SAP<SOURCE SID> from SAPSR3. the sap version is ECC6.0,DB is ORACLE10.2 on WIN NT.
after MMC opened, i get "SQL error in the database when accessing a table" error is coming. in SM21, I am getting "Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000 )
Database error 8103 at SEL access to table TBTCO
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
Database error 8103 at FET access to table TBTCP
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130339 sibqty_Q TY_00 " generated
Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000
> Short dump "081018 130339 sibqty_Q TY_00 " generated
Transaction Canceled 00 671 ( DBIF_RSQL_SQL_ERROR 20081018130339sibqty_QTY_00 SAPSYS 000
Delete session 001 after error 023
Database error 8103 at DEL access to table TMSALOGAR
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130432 sibqty_Q TY_00 " generated
Database error 8103 at FET access to table SNAP
Run-time error "DBIF_RSQL_SQL_ERROR" occurred
> Short dump "081018 130432 sibqty_Q TY_00 " generated
Transaction Canceled SY 002 ( SQL error in the database when accessing a table. )
Database error 8103 at FET access to table TSP02"
please find the st22 DUMP:
ow to correct the error |
Database error text........: "ORA-08103: object no longer exists"
Internal call code.........: "[RSQL/READ/TBTCO ]"
Please check the entries in the system log (Transaction SM21).
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
"SAPMSSY2" or "SAPMSSY2"
"INITIATE_JOB_START"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
The exception must either be prevented, caught within proedure
"INITIATE_JOB_START" "(FORM)", or its possible occurrence must be declared in
the
RAISING clause of the procedure.
|
please do me this favor if you know to avoid this problem..
thanks a lot..Hello Anuj,
This is because the COUNT(*) is returning a value which is longer than the INT4 data type it is expecting. If you restrict the selection by introducing a WHERE clause, then you won't get the dump:
DATA: dyn_from TYPE string,
dyn_where TYPE string,
gx_sql_err TYPE REF TO cx_sy_open_sql_error,
gv_text TYPE string.
dyn_from = `DD01L INNER JOIN DD02L ON DD02L~AS4LOCAL = DD01L~AS4LOCAL AND DD02L~AS4VERS = DD01L~AS4VERS`.
dyn_where = `DOMNAME LIKE 'Z%'`.
TRY .
SELECT COUNT(*) FROM (dyn_from) WHERE (dyn_where).
WRITE: / sy-dbcnt NO-GROUPING.
CATCH: cx_sy_open_sql_db INTO gx_sql_err,
cx_sy_dynamic_osql_semantics INTO gx_sql_err,
cx_sy_dynamic_osql_syntax INTO gx_sql_err.
ENDTRY.
IF gx_sql_err IS BOUND.
gv_text = gx_sql_err->get_text( ).
WRITE: / gv_text.
ENDIF.
BR,
Suhas -
Internal error when accessing a table -
Hi,
The program which is running as background was running for last 1 year, last two days the RFC call in the program is dumping.
In DUMP its showing Internal error when accessing a table
Error : DBIF_RSQL_SQL_ERROR
I checed the size of the table its quite huge for the application.
So there is no issue with table.
Please advise what causes these sort of error.
System is ECC 6.0
With SQL server 8.0
Regards,
ThomasThese are the system log i got it from SM21. For this error logs are as below
Very High Priority error
Details Page 2 Line 9 System Log: Local Analysis of onsaprp1 1
Time
Type
Nr
Clt
TCode
Grp
N
Text
15:43:09
DIA
009
300
AB
0
Run-time error "DBIF_RSQL_INTERNAL_ERROR" occurred
Run-time error "DBIF_RSQL_INTERNAL_ERROR" occurred
Details
Recording at local and central time........................ 11.02.2011 15:43:09
Task......
Process
User......
Terminal
Session
TCode
Program
Cl
Problem cl
Package
03084
Dialog work process No. 009
TOM
1
SAPMSSY1
T
Transaction Problem
SABP
Further details for this message type
Module nam
Line
Error text
absapsql
0786
HandleRsqlErrors
Documentation for system log message AB 0 :
The specified runtime error has occurred in the system.
Parameter
abcdefghijklmnopqrstuvwxyz .. DBIF_RSQL_INTERNAL_ERROR
Technical details
File
Offset
RecFm
System log type
Grp
N
variable message data
119
618840
l
Error (Module, Row)
AB
0
HandleRsqlErrors absapsql0786
High Priority error
Details Page 2 Line 18 System Log: Local Analysis of onsaprp1 1
Time
Type
Nr
Clt
TCode
Grp
N
Text
15:44:07
DIA
009
300
SMEN
BZ
Y
Unexpected return value 8 when calling up
Unexpected return value 8 when calling up
Details
Recording at local and central time........................ 11.02.2011 15:44:07
Task......
Process
User......
Terminal
Session
TCode
Program
Cl
Problem cl
Package
03084
Dialog work process No. 009
TOM
om-blr-l
1
SMEN
SAPLSMTR_NAVIGATION
K
SAP Web AS Problem
SBAC
Further details for this message type
Module nam
Line
Table Name
Field Name
dbrepolo
172
8
Documentation for system log message BZ Y :
When calling a function within the database interface, a return
value which cannot be processed by the calling function was
provided.
Technical details
File
Offset
RecFm
System log type
Grp
N
variable message data
120
11160
h
Database Error (Non-SQL)
BZ
Y
8 dbrepolo172
Edited by: Thomas Paul jr on Feb 14, 2011 6:36 AM
Edited by: Thomas Paul jr on Feb 14, 2011 6:38 AM -
How to access internal table data from webdynpro to Flex application.
Hi Connoisseur
The data transfer from Abap WebDeypro to flex island works well. I followed , there is an example from Thomas Jung (by the way as always Great Work) and Karthikeyan Venkatesan (Infosys) but this example covers simple type only.
There is no example with complex types like arrayCollection which handle the transfer of data from flex to WebDynpro.
i tried to do pass internal table value to flex-datagrid.but its not work.
i would like to know
1.how to access internal table data from webdynpro to Flex application.
2.how to pass the internal table to flex-datagrid.
2.how to pass dynamically in ADOBE flex.
3. how to do Flex is receiving the wd context data?
4. how can we update WD context with FLEX data.
Ple give me sample example and step by step procedure.
Regards
laxmikanthHi Laxmikanth,
Please refer this...
Flash island: update complex type from flex
Cheers..
kris. -
What is access sequence tables and how to use them in program?
hi all, I know a little about SD and access sequence tables, but I get a requriment like this:
condition type is a paramater
The condition types allowed in this report are: Note: A list of pre-defined condition types with their corresponding access sequence tables will be defined.
How can I make it? How can I use it in program to get the price?Hi,
An access sequence is a search strategy with the aid of which the SAP
System searches for valid condition records of a certain condition type.
For example, you can stipulate for a price that the SAP System first
searches for a price for a specific plant, and then for a generally
applicable price.
For condition types for which you wish to maintain conditions with their
own validity period, you must assign an access sequence. With this, you
define which fields the SAP System checks in searching for a valid
condition record.
e.g. When you create condition record (e.g. Purchasing condition record) you enter condition type, system asks you the key combination to enter the entries. These key combinations are nothing but the access sequence. On the basis of combination of condition table it will search record. e.g. when u maintain condition record with acc seq Material/plant combination, it will transfer the same record in PO when u enter same material and plant in the PO.
Example:
An access sequence has been assigned to condition type PB00 so that
prices can be maintained in purchasing info records and contracts.
No access sequence has been assigned to condition type RC00 because it
does not have a validity period of its own. In the standard system, it is
always maintained simultaneously with the price and is valid for the
period of the price.
For more help
http://www.sap-img.com/materials/steps-for-mm-pricing-procedures.htm
Regards,
Raj. -
Accessing XI Tables (ABAP Stack) from Java code
Hi,
IS it possible to access tables like SXMSPMAST, SXMSPEMAS directly from Java code without the use of any RFC or BAPI in between?
Cheers,
EarlenceI think it is technically possible, as you can get access to the JDBC Connector service using J2EE's JNDI feature ... Then you can use the internal DB datasource to read data from tables (read ONLY, cuz I'm not sure it is a good idea to update data "outside" the box, and reading can also have potiential perf or stability issue) ... Some (better) methods can also exist !
Chris
Edited by: Christophe PFERTZEL on Jan 15, 2010 3:07 PM -
Accessing dictionary tables from dynpro?
Hi all
As far as i know, there are 4 approches to access dictionary tables from webdynpro.
-entity bean
-sqlj
-jdbc
what are the advantages and disadvantages for all above?
and which one to go for?Hi swathi
See the persistence API--Adv and Disadvantages what ever you mentioned come under the persistence API
Relational Persistence
=================
SQL-based coding: expressive!
SQLJ: for static SQL, checked at design time,
recommended
JDBC: for dynamic SQL, can be combined with SQLJ
=======================
Object-relational Persistence
======================
SQL-free! Portable!
JDO: light-weight object persistence, Java-like dynamic
query language
EJB CMP: part of J2EE standard, relatively heavy-weight,SQL-like static query language
Regards,
Venkata Kalyan Karanam -
Accessing Java tables of XI within GUI/Java mapping
Hi,
I am looking for a way to access tables of a java dictionary within java/GUI mapping. Specifically, if it is possible some simple API to access java tables within user-defined functions.
I know you can access tables via JDBC/RFC lookups. But, this way more applies to external to SAP XI tables. Is there a more simpler way to access java native tables inside SAP XI.
Thank you in advance,
Dmitriy MindichHi Stephan,
I agree that first case should not be implemented. But, I would like to disagree on the second case. I am not talking about storing application data, but interface-related intformation, such is file generation id or date generation. This information is interface-specific, and unfortunately XI does not provide a way to store persistent variables inside XI.
There are a couple of options:
1. Use SEEBURGER's functionality. Unfortunately, I dont have the need to use EDI functionality of SAP, thus I dont want to buy SEEBURGER's license.
2. Use ABAP Mapping and store it inside tables inside ABAP-stack. However, as I said before this step would be performance intensive for me, since the majority of mapping in my case is done in Java/GUI mapping.
Based on these cases, I was thinking there should be an easier way to store/retrieve interface related information inside XI tables. And, since most of my mappings are Java-based, I was thinking I can use Java-stack to store persistent variables.
Would you agree, Stephan?
Regards,
Dmitriy Mindich -
ACCESSING MULTIPLE TABLES THRU ONE SELECT STATEMENTS
How to access multiple tables through one single select statement and also using where condition in it for multiple fields which are from different tables. please give me any example from any tables ....thanks in advance
See the below example code :
REPORT ZMM_COST no standard page heading
line-size 255
message-id zwave .
type-pools
type-pools : slis.
Tables
tables : mara,
makt,
mbew,
konp,
pgmi,
marc,
RMCP3,
sscrfields,
mvke.
Internal Table for MARC and MARA
data : begin of i_join occurs 0,
matnr like mara-matnr, " Material #
meins like mara-meins, " Unit of Measure
werks like marc-werks, " Plant
zzdept like marc-zzdept," Department
end of i_join.
Internal table for PGMI
data : begin of i_pgmi occurs 0,
werks like pgmi-werks, " Plant,
nrmit like pgmi-nrmit, " Material #
wemit like pgmi-wemit, " Plant
end of i_pgmi.
Internal Table for MBEW
data i_mbew like mbew occurs 0 with header line.
Internal Table for Output
data : begin of i_output occurs 0 ,
matnr like mara-matnr, " Material #
maktx like makt-maktx, " Material Desc
VPRSV like mbew-VPRSV, " Price Control Indicator
VERPR like mbew-VERPR, " Moving Avg Price
meins like mara-meins, " Base Unit of Measure
STPRS like mbew-STPRS, " Standard Price
LPLPR like mbew-LPLPR, " Current Planned Price
ZPLPR like mbew-ZPLPR, " Future Planned Price
VPLPR like mbew-VPLPR, " Previous Planned Price
kbetr like konp-kbetr, " Sales Price
KMEIN like konp-KMEIN, " Sales Unit
margin(5) type p decimals 2,
vmsta like mvke-vmsta, " Material Status.
end of i_output.
Internal Table for A004
data : i_a004 like a004 occurs 0 with header line.
Variables
data : wa_lines type i,
wa_maktx type makt-maktx,
v_flag type c.
ALV Function Module Variables
DATA: g_repid like sy-repid,
gs_layout type slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user type slis_exit_by_user.
DATA: gt_fieldcat type slis_t_fieldcat_alv,
gs_print type slis_print_alv,
gt_events type slis_t_event,
gt_list_top_of_page type slis_t_listheader,
g_status_set type slis_formname value 'PF_STATUS_SET',
g_user_command type slis_formname value 'USER_COMMAND',
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_top_of_list type slis_formname value 'TOP_OF_LIST',
g_end_of_list type slis_formname value 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
data : gr_layout_bck type slis_layout_alv.
Selection-screen
selection-screen : begin of block blk with frame title text-001.
parameters : p_werks like marc-werks default '1000' obligatory.
select-options : s_dept for marc-zzdept obligatory,
s_matnr for mara-matnr,
s_mtart for mara-mtart,
s_vprsv for mbew-VPRSV,
s_PRGRP for RMCP3-PRGRP MATCHCODE OBJECT MAT2 ,
s_vmsta for mvke-vmsta.
selection-screen: end of block blk.
*SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
*PARAMETERS: p_vari LIKE disvariant-variant.
*SELECTION-SCREEN END OF BLOCK b3.
At slection screen events *
*-- Process on value request
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
Initialization *
Initialization.
g_repid = sy-repid.
sscrfields-functxt_01 = 'Clear Selection'.
selection-screen function key 1.
AT SELECTION-SCREEN.
case sscrfields-ucomm.
when 'Clear Selection' or 'FC01'.
clear: s_matnr,
p_werks.
refresh: s_matnr,
s_dept,
s_mtart,
s_vprsv,
s_PRGRP,
s_vmsta.
endcase.
Start-of-selection.
start-of-selection.
Clear the all data.
perform clear_data.
Get the data from PGMI Table
perform get_pgmi.
Get the data from MARC and MARA Table
perform get_mara_marc.
Get the data from MBEW Table
perform get_mbew.
Move the data into OUTPUT Table
perform move_output_internal.
*end-of-selection.
end-of-selection.
if not i_output[] is initial.
ALV Function Module
perform print_alv.
endif.
*& Form get_pgmi
Select the data from PGMI Table
FORM get_pgmi.
clear v_flag.
If Product group has a value at Selection-screen.
if not s_prgrp is initial.
select werks nrmit wemit from pgmi into table i_pgmi
where prgrp in s_prgrp
and werks = p_werks
and wemit = p_werks.
v_flag = 'X'.
endif.
ENDFORM. " get_pgmi
*& Form get_mara_marc
Select the data from MARA and MARC
FORM get_mara_marc.
if v_flag = 'X'.
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
for all entries in i_pgmi
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart
and a~matnr = i_pgmi-nrmit
and b~werks = i_pgmi-werks.
else.
Get the data from MARA and MARC Table
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart.
endif.
clear wa_lines.
describe table i_join lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_join by matnr werks zzdept.
ENDFORM. " get_mara_marc
*& Form get_mbew
Select the data from MBEW Table
FORM get_mbew.
Get the data from MBEW.
select * from mbew into table i_mbew
for all entries in i_join
where matnr = i_join-matnr.
clear wa_lines.
describe table i_mbew lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_mbew by matnr bwkey.
ENDFORM. " get_mbew
*& Form move_output_internal
Final Results
FORM move_output_internal.
loop at i_join.
clear wa_maktx.
Compare the data with MVKE Table
select single vmsta from mvke into mvke-vmsta
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'
and vmsta in s_vmsta.
if sy-subrc ne 0.
continue.
else.
i_output-vmsta = mvke-vmsta.
endif.
read table i_mbew with key matnr = i_join-matnr
bwkey = i_join-werks
binary search.
if sy-subrc eq 0.
Price Control Indicator
i_output-VPRSV = i_mbew-VPRSV.
Moving Average Price
i_output-VERPR = i_mbew-VERPR / i_mbew-peinh.
Standard Price
i_output-STPRS = i_mbew-STPRS / i_mbew-peinh.
Current Planned Price
i_output-LPLPR = i_mbew-LPLPR / i_mbew-peinh.
Future Planned Price
i_output-ZPLPR = i_mbew-ZPLPR / i_mbew-peinh.
Previous Planned Price
i_output-VPLPR = i_mbew-VPLPR / i_mbew-peinh.
Base Unit of Measure - Added by Seshu 01/09/2007
i_output-meins = i_join-meins.
else.
continue.
endif.
Get the sales Price.
perform get_sales_data.
if i_mbew-VPRSV = 'V'.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_mbew-VERPR )
/ i_output-kbetr ) * 100 .
endif.
else.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_output-stprs )
/ i_output-kbetr ) * 100 .
endif.
endif.
Get the material Description from MAKT Table
select single maktx from makt into wa_maktx
where matnr = i_join-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_output-matnr = i_join-matnr.
i_output-maktx = wa_maktx.
endif.
append i_output.
clear : i_output,
i_join,
i_mbew.
endloop.
ENDFORM. " move_output_internal
*& Form get_sales_data
Get the Sales Price for each material
FORM get_sales_data.
Get the data from A004 table to get KNUMH
Added new field Sales Unit - Seshu 01/09/2006
refresh : i_a004.
clear : i_a004.
data : lv_kbetr like konp-kbetr," Condition value
lv_KPEIN like konp-kpein , "per
lv_KMEIN like konp-KMEIN. " Sales Unit
select * from a004 into table i_a004
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'.
if sy-subrc eq 0.
sort i_a004 by DATAB descending.
Get the Latetest Date
read table i_a004 with key matnr = i_join-matnr
vkorg = '0001'
vtweg = '01'
binary search.
Get the Sales Value
select single kbetr KPEIN KMEIN from konp
into (lv_kbetr,lv_KPEIN, lv_KMEIN)
where knumh = i_a004-knumh
and kappl = i_a004-kappl
and kschl = i_a004-kschl.
if sy-subrc eq 0.
i_output-kbetr = lv_kbetr / lv_KPEIN.
i_output-KMEIN = lv_KMEIN.
endif.
endif.
clear : lv_kbetr,
lv_kpein,
lv_KMEIN.
ENDFORM. " get_sales_data
*& Form print_alv
ALV Function Module
FORM print_alv.
Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].
gr_layout_bck-edit_mode = 'D'.
gr_layout_bck-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gr_layout_bck
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = g_save
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_output
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
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. " print_alv
*& Form fieldcat_init
Fieldcat
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'MARA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material'.
ls_fieldcat-seltext_M = 'Material'.
ls_fieldcat-seltext_S = 'Material'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-OUTPUTLEN = 35.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Price Indicator
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPRSV'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Price Control Indicator'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Moving Avg Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VERPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Moving Avg Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Base Unit of Measure
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MEINS'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Base Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Standard Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STPRS'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Standard Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Current Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Current Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Future Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Future Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Previous Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Previous Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KBETR'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Unit
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KMEIN'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
% of Gross Margin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MARGIN'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = '% of Gross Margin'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Status
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VMSTA'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material Status'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM. " fieldcat_init
**& Form f4_for_variant
text
*FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
*ENDFORM. " f4_for_variant
*& Form clear_data
Clear the Internal table
FORM clear_data.
clear : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
refresh : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
ENDFORM. " clear_data
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN '&IC1'.
read table i_output index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD i_output-matnr.
SET PARAMETER ID 'WRK' FIELD p_werks.
if not i_output-matnr is initial.
call transaction 'MD04' and skip first screen.
endif.
ENDCASE.
ENDFORM.
Reward Points if it is helpful
Thanks
Seshu
Maybe you are looking for
-
Personal File Sharing not in Sharing list
Hi. I am running Mac OS X Tiger 10.4.8 and I would like to turn on the Personal File Sharing service under Sharing from the System Preferences menu. Unfortunately, the only services available in the list are Remote Login, Apple Remote Desktop and Rem
-
Can I boot Vista OS from an external USB drive
Hi, I would like to install Vista onto an external (USB) drive and boot from that occasionally whilst retaining XP on the internal drive. Is this possible please. I realise I would need to change the boot order in BIOS. I know I could create a dual b
-
How to change content name showing in assignments panel?
This seems like such a simple question but I've been googling and searching the forums for 30 minutes now with no luck. So I'm wondering if it's even possible at all. How can one change the name of the content in the assignments panel? The names gi
-
How do I get iCloud to work on my iphone
I cannot seem to set up iCloud on my iphone. Apple updated my phone yesterday to 6. I have lost my calendar and text messages only and have no way of retrieving it as itunes had a technical problem happening, while I was doing my back up. Apple supp
-
Any diffrent access for the null value between oracle 9i and 11g?
I'v got a tmp result set by a SQL that with a group by rollup (code) clause, and the last row is the totle number and column 'code' is null. when i left out join (use (+)) the result set with the code table , in 9i,i can not get the last totle number