FCI - Origem do material / Classificação Fiscal.
Pessoal, Boa noite.
Gostaria de pedir ajuda de vocês para me certificar que estamos agitando da forma correta aqui no projeto.
Entretanto, antes de falar sobre o FCI, preciso detalhar a minha o cenário..
Estou em um projeto, onde a empresa produz veículos.
Quando falamos em veiculo, vamos pensar da seguinte forma.
Por exemplo.
Familia Pailo
Palio Economy
Palio Sport
Palio 1.4
Familia Punto
Punto 1.4
Punto 1.6
Punto Sport
Adote que cada Família de veiculo (Família Palio, Família Punto) representa um código de Material na MARA.
No FCI, a regra aplicada seria:
Se o conteúdo de importação do material (MARA) ultrapassar 40%, a Origem do Material seria 3 e Classificação Fiscal 4 obtendo o imposto com 4% de ICMS.
Entretanto, o conteúdo de importação no caso deve ser visto por tipo de veículos (Palio Economy, Sport, 1.4, Punto 1.4, Punto 1.6, Punto Sport) que no caso controlamos com o numero do Valuation Type.
Portanto, para cada veiculo eu consigo atualizar a origem do material, e até aqui ok!
Porém, a classificação fiscal é a nível organizacional(e não por veiculo), e se eu modificar a classificação fiscal eu estaria modificando para toda a organização de vendas, afetando assim veículos que não teria conteúdo importando.
Infelizmente ainda não domino parte de impostos, e gostaria de saber qual seria o impacto em modificar o tax Classification, sendo que eu teria veículos com conteúdo importando e outros não, afinal isso indifere ou não para a venda?
Desde já muito obrigado!
Enzo Sevilhano
SAP - SD
Bom Dia Sergio,
Primeiramente, obrigado pela resposta, realmente irei adotar a não atualização da classificação fiscal.
Eu realmente fiquei com duvida, pois se você visualizar o IBRX, temos lá os campos de 1 a 4, onde o 4 representa material importando e considerando uma vez que a origem do material seria importada, pensei em atualizar classificação fiscal também.
De qualquer maneira, obrigado e vou prosseguir com os testes.
Obrigado
Enzo Sevilhano
Similar Messages
-
Aliquota de imposto / origem do material
Na empresa onde trabalho deve ser implantado a resolução 13 do senado federal FCI. O SAP orienta a implantação do split valuation, mas nesta empresa não querem adotar esta solução devido ao impacto que ela causa.
Foi sugerido de ser criado uma solução Z onde uma das tabelas Z seria utilizada para associar material, grupo de mercadoria e origem, onde a chave desta tabela seria material, grupo de mercadoria.
Nesta tabela poderia ser realizada varias associações, independente do grupo de mercadoria que está definido no cadastro mestre do material.
Os documentos criados que fossem predecessores para criação da nota fiscal, seria desligado o controle de mensagem de erro para o grupo de mercadoria, onde a informação seria originada da tabela Z criada.
Diante disso, segue abaixo os questionamentos para alguma ajuda:
A- Seria possível desligar o controle de integridade através de mensagem, para um grupo de mercadoria que não esteja definido no mestre do
material?
B- Para efeito de retorno de alíquota de imposto e posteriormente o calculo do imposto, seria possível efetuar uma alteração no SAP para buscar a informação do documento que será gerado a nota fiscal e não a que está cadastrada no mestre do material?
C- Seria possível desligar o controle de integridade para gravar uma origem na nota fiscal diferente da cadastrada no mestre do
material?
exemplo:
1- mestre do material definido com:
código do material - 1000
código do grupo de mercadoria - 00
2- tabela Z definida com 2 registros com mesmo material e com grupo de mercadorias diferente do informado no mestre de material:
código do material - 1000
código grupo de mercadoria - 01
código do material - 1000
código grupo de mercadoria - 03
3- documento predecessor para geração da nota fiscal com a informação de:
código do material - 10
código do grupo de mercadoria - 03
4- Forma pretendida do SAP buscar a alíquota de imposto e posteriormente efetuar o calculo do imposto:
4.1 - Passar como parâmetro o material 10 e o grupo de mercadoria 03 do documento que está sendo criado para gerar a nota fiscal;
4.2 - Impedir que o SAP leia as informações definidas no mestre de material codigo do material 1000 e código de grupo de mercadoria 00;
4.3 - Retornar a alíquota de acordo com os parâmetros passados no item 4.1.Bom Dia Sergio,
Primeiramente, obrigado pela resposta, realmente irei adotar a não atualização da classificação fiscal.
Eu realmente fiquei com duvida, pois se você visualizar o IBRX, temos lá os campos de 1 a 4, onde o 4 representa material importando e considerando uma vez que a origem do material seria importada, pensei em atualizar classificação fiscal também.
De qualquer maneira, obrigado e vou prosseguir com os testes.
Obrigado
Enzo Sevilhano -
CFOP aparecendo na Nota Fiscal de Serviço
Pessoal, bom dia!
Estamos num projeto de implementação da NFe 3.10 e atualização de Support Package e deparamos com a seguinte situação:
No lançamento de uma nota fiscal de serviço, com um IVA de serviço, o campos cfop, utilização do material e origem do material estão aparecendo no item da nota fiscal, mas não deveriam.
No ambiente de Produção, NFe 2.0, corretamente esses mesmos campos não aparecem no item da nota fiscal.
O mais estranho é que mesmo que eu altere o status desses campos no controle de tela, no detalhe do item eles ficam ocultos, mas na linha do item da nota fiscal eles continuam aparecendo.
Alguém pode dar uma dica?
Desde já agradeço.Nao, a solucao SAP NFE é para nota fiscal de mercadorias modelo 55 (SEFAZ, modelo nacional), que substitui os modelos de nF 1/1A.
Há uma proposta de padrao nacional que, infelizmente, só a prefeitura de BH está seguindo...
Caso haja um acordo entre um numero razoavel das principais prefeituras do Brasil, a SAP irá avaliar a possibilidade de incluir essa solucao, senao não há como provermos uma solucao especifica para cada cidade.
Att,
Henrique. -
Pessoal, bom dia!
Vejam se alguém já passou por algo parecido em algum projeto...
Estou com uma demanda pra alterar alguns parametros do processo de transferência de crédito de ICMS, que são:
1- A quantidade deverá ser preenchida com “0”.
2- O valor unitário deve ser “0”.
3- O campo de unidade de medida “Vazio”
4- A NCM não deverá ser vazia, mas ser preenchida com “00”.
5- O CST deverá ser “090”.
A solução para os pontos 1, 2 e 3 foi criar um enhancement na função J_1B_NFE_PROCESS_OUTBOUND relacionada a J1B1N para alterar os valores digitados pelo usuário assim que a nota estiver sendo criada. Para o ponto 4, a solução foi criar um NCM "00" para utilização do usuário.
E, no ponto 5, a solução foi orientar o usuário a optar pela origem do material "0" e optar pelo direito fiscal IC9 (Outros) que atribuirá a tributação 90, formando assim o 090 esperado.
O problema é:
Ao dar saída na nota fiscal pela J1B3N, ela está sendo rejeitada pelo fato dos campos 'pMVAST (Percentual da margem de valor Adicionado do ICMS ST), pRedBCST (Percentual da Redução de BC do ICMS ST), vBCST' (Valor da BC do ICMS ST) não estarem sendo preenchidos.
Sendo assim, como posso resolver esse ponto?
Em anexo está a tela do preenchimento da Writer com os devidos parametros e impostos, e está também o IDOC que foi gerado com os campos em branco.
Desde já agradeço a atenção.Allan, boa tarde!
Obrigado pela sua resposta, mas, conforme venho conversando com o fiscal resposável do projeto, o cenário é esse mesmo.
Seguem abaixo e em anexo as regras Fiscais para emissão da nota de transferência de crédito de ICMS:
Orientação de Preenchimento NF-e:
Transferência de crédito
A nota fiscal eletrônica (NF-e) também será emitida nas hipóteses de transferências de crédito acumulado de ICMS em razão de exportação, diferimento ou redução da base de cálculo.
De acordo com a legislação, há regras a serem observadas para a emissão da NF-e referente a essa transferência de crédito. Resumidamente, alguns procedimentos comuns que poderão ser seguidos.
Para emitir a NF-e, é necessário informar nos campos próprios:
1. Como destinatário, o nome, o endereço e os números de inscrição estadual e no Cadastro Nacional de Pessoa Jurídica (CNPJ) do contribuinte ao qual se está efetuando a transferência;
2. Nas Informações Complementares do quadro “Dados Adicionais”, a expressão “Transferência de crédito acumulado de ICMS, nos termos (indicar o base legal da transferência)” e o valor, por extenso, do crédito transferido. No aplicativo gratuito emissor da NF-e, essa informação constará no campo “Informações Complementares de interesse do contribuinte” da aba “Informações Adicionais”;
3. No local destinado ao valor da operação do quadro “Cálculo do Imposto”, o valor do crédito acumulado transferido (no aplicativo gratuito de NF-e, esse valor será informado no Valor Total bruto). Nos demais campos, preencher com “0” (zero) para todos locais numéricos e obrigatórios nos quais não consta orientação específica - apenas um dígito “0” em cada, pois a NF-e trabalha com campo preenchido;
4. Como natureza da operação: “Transferência de Crédito Acumulado de ICMS”;
5. No campo “Finalidade de emissão” informar “NF-e de Ajuste”;
6. Os CFOP e CST serão os códigos 5.601/5.602 e 090, respectivamente;
7. A Nomenclatura Comum do MERCOSUL (NCM) será informada a expressão numérica “00”;
8. A “Descrição do Produto” será informada a expressão “Transferência de Crédito Acumulado de ICMS”;
9. A situação tributária do PIS e da COFINS será “Operação sem incidência da Contribuição; e
10. A “Modalidade do frete” indicar “Sem frete”.
8. Código de Situação Tributária – informar “90”. Página 168 do Manual de Integração.
Na Nota Técnica 2013/005, ainda é informado que os campos 'pMVAST, pRedBCST e vBCST' devem ser carregados no XML, e por se tratar de tranferência de crédito, os valores devem ser “zerados”.
Aplicando o imposto ICS3, consigo inserir zeros nos campos indicados acima. O problema é que a NF é rejeitada novamente só que com erro no campo vBCSTRet (Valor da BC do ICMS ST retido), pois ao zerar os campos acima acabo obrigatoriamente atribuindo zero ao campo vBCSTRet, fato que não deve ocorrer. -
To show all months of qty values for each fiscal year in report?
Our cube contains different fiscal years of order qty/delivered qty for a material (e.g. material A). We use fiscal year variant V9 (Oct. - Sep). We would like to generate the following query result to list the material, order qty, fiscal year, and then for each calender month, the delivered qty value for the corresponding fiscal year:
Column title:
Material --- Order Qty --- Fiscal Year --- Oct --- Nov --- Dec --- Jan --- Feb --- Mar --- Apr --- May --- Jun --- Jul --- Aug --- Sep
Just give two rows of data for material A:
1st row data example:
A (material) --- 23 (Order Qty) --- 2006 (fiscal year) --- 2 (delivered qty in Oct of the calendar year 2005 ) --- 4(delivered qty in Nov of the calendar year 2005 ) ---1 (delivered qty in Dec of the calendar year 2005 ) --- 5 (delivered qty in Jan of the calendar year 2006 ) --- .... 2 (delivered qty in Sep. of the calendar year 2006)
2nd row data example:
A (material) --- 45 (Order Qty) --- 2007 (fiscal year) --- 3(delivered qty in Oct of the calendar year 2006 ) --- 6 (delivered qty in Nov of the calendar year 2006 ) ---1 (delivered qty in Dec of the calendar year 2006 ) --- 5 (delivered qty in Jan of the calendar year 2007 ) --- .... 2 (delivered qty in Sep. of the calendar year 2007)
How to generate this query?
Thanks!hi Chandran,
Actually in each row data for material in different fiscal year, all the KFs in columns should be restricted to the fiscal year value. What we do is to use selections other than structure or RKF. What we is following listed in details that you can check if what we do is correct:
Under KF structure:
1. Create a selection for the 1st KF (Order Qty). In this selection, Order Qty is restricted with the characteristic 0FISCYEAR.
2. Create a formular as 2nd KF for the FY value. This formula KF use the value of a formular variable with Replacement Path of the the characteristic 0FISCYEAR. But somehow this KF value shows "X" values in this column. We defined this Replacement Path variable with the Reference Characteristic as 0FISCYEAR and all others keep default. But don't know why this column shows "X" values. We also add 0FISCYEAR to the row, and find the one does have data in the row. Any idea why put it in formular variable onto column not working?
3. Create a selecction for the 3rd KF (Oct). In this selection, restrict Delivered Qty with the characteristic 0CALMONTH2 (Calendar month) and further restrict 0CALMONTH2 to a fixed value: October
4. Create a selecction for the 4th KF (Nov). In this selection, restrict Delivered Qty with the characteristic 0CALMONTH2 (Calendar month) and further restrict 0CALMONTH2 to a fixed value: November.
Then the following steps are similar to step 3 and 4 to create all other Month columns. We wonder in all these selections, would we have to restrict them further with 0FISCYEAR?
Therefore we've got two questions:
1. Why in step 2, the formular variable doesn't work and the FY column shows "X" values?
2. Do we need to further restrict the delivered qty with the characteristic 0FISCYEAR for each month column which corresonding to the fiscal year in the same row?
Thanks alot and we are keeping giving you reward points! -
Zona Franca ICMS+IPI BXZF não desconto - Ordem de Vendas
Boa tarde;
Estou tentanto realizar uma configuração de um cenário Zona Franca para produtos importados no qual terão incidência de imposto ICMS+IPI.
O cenário esta configurado desta forma:
1) Cenário normal venda Zona Franca de Produto Nacionais. Sem incidência de impostos.
- Código do Imposto I1.
- IVA SZ dispara a linha de desconto BXZF no qual dá o desconto ZF - OK
2) Cenário de itens importados - materiais com origem "1", "2" ou "8" - Incidência de ICMS+IPI.
- Código do Imposto - I3 - ICMS+IPI
- Deve trazer o código IVA "SD" disparando cálculo de ICMS.
- BXZF é RefConType da IBRX.
- Não deve disparar a linha BXZF.
- BXZF - traz o IVA SZ.
Cenário Configurado:
- Criado uma nova tabela 972 - País, ClassCliente, Classi Mat, Origem Material.
- Sequencia de Acesso IZOF - a tabela 972
- Condição DIZF - Seq Aces - IZOF.
- Quando crio a ordem de vendas o sistema trata desta maneira:
1) Ele verifica a origem do material encontra "1"
2) Determina na condição DIZF - IVA "SD"
3) BXZF é um RefconType da IBRX
4) Por isso BXZF - determina "SD"
Entretanto, a linha de desconto BXZF esta trazendo o desconto ZF no qual se tenho o IVA SD não deveria trazer a linha.
Alguém tem alguma ideia de como fazer a configuração?
OBS: ZZOF é a mesma SeqAce - IZOF.
Muito Obrigado
Rodrigo VieiraOlá André;
Então pelo que entendi para o tipo de materiais com origem 1,2 e 8 Importados que não quero que aplique a linha de desconto se hoje tenho uma tabela de condição criada 972 972 - País, ClassCliente, Classi Mat, Origem Material e associada a sequência de acesso e condição DIZF conforme abaixo irá encontrar e SD, porém irá aplicar o desconto.
Registro de condição cadastrada.
BR 2 1 1 Foreign - imported directly 100,000 % 01.04.2014 31.12.9999 SD
BR 2 1 2 Foreign - acquired nationally 100,000 % 01.04.2014 31.12.9999 SD
BR 2 1 8 National - with import content over 70% 100,000 % 01.04.2014 31.12.9999 SD
Tenho um cenário que na mesma pricing terie produtos Nacionais origem "5" e Importados origem 1,2 e 8.
Para o primeiro a linha de desconto precisa ser disparada por causa da isenção..
Então o SZ na condição DIZF irá ser disparada e o desconto na BXZF séra aplicada.
Entretando, como posso fazer para que não se aplique o desconto..
As únicas possibilidades foi criado sequência de acesso forçando o SD, porém como a condição DIZF é determinada porque encontra origem ele força o desconto na BXZF
Tem alguma sugestão ou ideia de ocmo posso configurar?
Abs
Rodrigo Vieira -
Hi Experts,
I have a issue with DSO.We extracted data from R/3 in to BI and send it in to DSO.We are getting data from R/3 to PSA with right records with init load.But from PSA to DSO,we are getting duplicate records for 2 invoices.We have 2 invoices say xxxx01 and xxxx02 have problems in DSO.
XXXX01 has 3 items(10,20,30) created on April2008 with billing Doc type A
XXXX02 has 2 Items(10,11) created on April2008 with billing Doc type B
But in DSO we are getting extra Item record for each of document
i.e XXXX 01 has 4items(10,20,30,10).3 items(10,20,30) created on April 2008 with billing Doc type A.One Item(10) created on June 2008 with billing Doc Type C(this is not in R/3 so This extra one).
XXXX02 has 3 items(10,11,10) .First 2Items(10,20) are original ones created on April 2008 with Billing type B.One extra Item(10) created on June 2008 with Billing Doc Type C(this Item is not in R/3).
We have key fields in DSO is Sales Document,Material,Billing Item,Fiscal variant.I din't add Document Type,Document Category,Calender day in Key Fields but they are in Data Fields.
I am not sure how can I overcome this issue either adding Document type ,Calender day,Document Category in DSO or Put some fields in Semantic group.
Please advise me and tell me some possible solutions.
We ran setup tables with init and ran infoPackage and ran delta Infopackage too in Testing box.If I change the design in Dev box and Transport in to the test box,Hope I need to fill the Setup tables again right.Please advise me.
Thanks,
Ran.Hi,
Use this key fields and sure it will solve.
Doc no.,Doc Item. for Orders
Bill Item and Bill no. for Invoices
Delivery No. and Delivery item no. for deliveries.
Moreover check ur transformations once.
Cheers,
shana -
Hi Experts,
I want to prepare a new custom report in which the PO number should appear. I was advised to use EKBE table. On checking I found that I can pass only Material doc# and Fiscal Year and No company code field is found. Is it reliable to use only to input values and try to fetch the PO number? I am not sure if there could be more documents across company codes since the number range is set as company code level. Can you suggest any alternative?
I have already searched for similar topic but could not find the correct answer.
Please help.
Thanks in advance.
SunilHi Both,
If I use MSEG table, I must use GR-MM document. As per my knowledge, IR document (MM/FI) won't reflect in MSEG table.
If GR entry is done first, then I can fetch the AWKEY field from IR-FI doc to get the MM doc#. If the IR entry is done first, (without GR entry posted on PO line) then it is not very easy to fetch the GR-MM document number at a later point of time also.
If the PO# is unique, independent from company code and year, then there are no issues, the below logic will work.
Pass the IR-FI Document number to BKPF with BUKRS&GJAHR and take get IR-MM document (AWKEY - 10 +4). Then pass this to EKBE table with BELNR and GJAHR then pick the EBELN (PO#) and EBELP (line item).
Please correct if I am not right.
Thanks in advance! -
Hi,
Please help me in this.
1) Create the selection screen with the following fields on it.
S_REQUESTOR for ZSWAPHISTORY- REQUESTOR
S_APPROVER for ZSWAPHISTORY- APPROVER providing range
S_to_customer for ZSWAPHISTORY- to_customer providing range
S_from_customer for ZSWAPHISTORY- from_customer providing range
S_MRPC for MARC-DISPO providing range
S_MATNR for MARA-MATNR providing range
S_APPR_DATE for ZSWAPHISTORY- APPR_DATE Default to yesterdays date
S_QUAN for ZSWAPHISTORY-quan
2) Validate the fields entered in the selection screen.
3) Check the user authorizations for this report.
4) Select the entries from the table ZSWAPHISTORY into an internal table based on the input from the selection screen and the value of the field ZSWAPHISTORY -STATUS is APPROVED.
5) Then select the MRP Controller ID (DISPO) from the Table MARC for all entries in the internal table where MARC-MATNR equals to the internal table -material number.
6) Move the field value of MRP Controller ID (DISPO) into the final internal table for the corresponding entries.
7) Declare the Filed Catalogue with the fields that are to be displayed in the ALV
Please help to create this , iam new to this area.
Thanks
AliHi
See the sample code of ALV and do accordingly
Since you are using a Z table it is not clear to create
report ZRGRIRNA no standard page heading
line-count 65
line-size 255
message-id mm.
GR IR Detail Report *
Description : The output has to be displayed
in the ALV Grid format with the Selection *
screen appearing on the output. In The Output *
Subtotals for Vendor, Plant, Period, Material,*
Valuation Class, Purchase Order,Cost Center, *
Cost Element and Receipt Date are displayed *
after sorting the data by same fields. *
Declaration for Tables
tables: t001, " Company Codes
t001w, " Plants/Branches
lfa1, " Vendor Master
ska1, " GL Account Master
mara, " Material Master
mbew, " Material Valuation
ekko, " PO Header Data
cska, " Cost Elements
csks, " Cost Centers
bsis, " GL Accounts: Open Items Data
bkpf. " Accounting Doc: Header Data
Type-pools
Type pools for ALV display
type-pools : slis.
Global variables
data: g_repid like sy-repid,
g_exit type c,
g_events type slis_t_event,
g_list_top_of_page type slis_t_listheader,
g_exit_caused_by_caller,
g_exit_caused_by_user type slis_exit_by_user,
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_variant like disvariant,
g_save.
Declaration for Constants
constants : c_x type c value 'X', " Flag
c_c type c value 'C', " Flag
c_l type c value 'L', " Flag
c_a type c value 'A', " Line Type
c_h type c value 'H', " Dr/Cr
c_s type c value 'S', " Line Type
c_mkpf(4) type c value 'MKPF'. " Table
Declaration of Internal Tables
Internal Table for BSIS Table data
data: begin of i_bsis occurs 0,
bukrs like bsis-bukrs, " Company Code
hkont like bsis-hkont, " GR IR Account
gjahr like bsis-gjahr, " Fiscal Year
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
budat like bsis-budat, " Receipt Date(Posting)
monat like bsis-monat, " Period
end of i_bsis.
Internal Table for BSEG Table data
data: begin of i_bseg occurs 0,
bukrs like bsis-bukrs, " Company Code
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
gjahr like bsis-gjahr, " Fiscal Year
shkzg like bseg-shkzg, " Dr/Cr Indicator
lifnr like bseg-lifnr, " Vendor Code
matnr like bseg-matnr, " Material No
ebeln like bseg-ebeln, " Purchase Order
ebelp like bseg-ebelp, " PO Item
werks like bseg-werks, " Plant
menge like bseg-menge, " PO Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Amount in Local Currency
wrbtr like bseg-wrbtr, " Amount in Trans.Currency
end of i_bseg.
Internal Table for BKPF Table data
data: begin of i_bkpf occurs 0,
bukrs like bkpf-bukrs, " Company Code
belnr like bkpf-belnr, " Acc Document
gjahr like bkpf-gjahr, " Fiscal Year
waers like bkpf-waers, " Trans. Currency
awkey like bkpf-awkey, " Object Key
awtyp like bkpf-awtyp, " Reference Procedure
end of i_bkpf.
Internal Table for MSEG Table data
data: begin of i_mseg occurs 0,
mblnr like mseg-mblnr, " Material Document
mjahr like mseg-mjahr, " Fiscal Year
bwart like mseg-bwart, " Movement Type
matnr like mseg-matnr, " Material No
menge like mseg-menge, " PO Quantity
meins like mseg-meins, " UOM
end of i_mseg.
Internal Table for MBEW Table data
data: begin of i_mbew occurs 0,
matnr like mbew-matnr, " Material No
werks like mbew-bwkey, " Plant
bklas like mbew-bklas, " Valuation Class
end of i_mbew.
Internal Table for EKPO Table data
data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln, " Purchase Order
ebelp like ekpo-ebelp, " PO Item
matnr like ekpo-matnr, " Material No
txz01 like ekpo-txz01, " Material Text
end of i_ekpo.
Internal Table for EKKN Table data
data: begin of i_ekkn occurs 0,
ebeln like ekkn-ebeln, " Purchase Order
ebelp like ekkn-ebelp, " PO Item
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
end of i_ekkn.
Internal Table for LFA1 Table data
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, " Vendor
name1 like lfa1-name1, " Name
end of i_lfa1.
Declaration of Output Internal Table
data: begin of i_final occurs 0,
lifnr like lfa1-lifnr, " Vendor
werks like bseg-werks, " Plant
monat like bsis-monat, " Period
matnr like mara-matnr, " Material Number
bklas like mbew-bklas, " Val Class
ebeln like bseg-ebeln, " PO
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
budat like bsis-budat, " Rec. Date
name1 like lfa1-name1, " Vendor Name
belnr like bsis-belnr, " FI Document
bwart like mseg-bwart, " Movement Type
txz01 like ekpo-txz01, " Material Text
menge like bseg-menge, " Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Local Amount
wrbtr like bseg-wrbtr, " Tran.Amount
waers like bkpf-waers, " Tran.Currency
status type c, " Material Status
end of i_final.
Internal table to hold field catgory data
data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
Structure
data: x_layout type slis_layout_alv, " Structure-layout
x_fldcat like line of i_fldcat, " Structure-field catagory
x_sort like line of i_sort. " Structure-Sort/Subtotals
Selection screen
selection-screen : begin of block b1 with frame title text-000.
parameters:
p_bukrs like t001-bukrs obligatory, " Company Code
p_grira like ska1-saknr default '0241101000' obligatory. " Account
select-options:
s_budat for bkpf-budat, " Posting Date
s_werks for t001w-werks, " Plant
s_lifnr for lfa1-lifnr, " Vendor
s_matnr for mara-matnr, " Material Number
s_kostl for csks-kostl, " Cost Center
s_kstar for cska-kstar, " Cost Element
s_ebeln for ekko-ebeln, " Purchase Order
s_monat for bsis-monat. " Period
selection-screen skip.
parameters:
p_incmt as checkbox default 'X',
p_incnm as checkbox default 'X'.
selection-screen end of block b1.
Initialization
initialization.
g_repid = sy-repid.
perform layout_init using x_layout.
perform eventtab_build using g_events[].
g_variant-report = g_repid.
g_save = 'A'.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
perform validate_screen.
Start of selection
start-of-selection.
Read Data from Database Tables
perform read_data.
End of selection
end-of-selection.
Build layout report layout.
perform populate_layout_stucture.
Perform build_field_catalog and Sort Table
perform build_field_catalog.
perform build_sort_totals.
List Header for Top-Of-Page
perform comment_build using g_list_top_of_page[].
Call list viewer function module
perform call_list_viewer .
****************Form - Routines**************************************
Form : layout_init
Description : Form to Build layout for list display
form layout_init using rs_layout type slis_layout_alv.
rs_layout-detail_popup = c_x.
endform.
Form : Eventtab_build
Description : Registration of events to happen during list display
form eventtab_build using rt_events type slis_t_event.
Registration of events to happen during list display
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = rt_events.
read table rt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move g_top_of_page to ls_event-form.
append ls_event to rt_events.
endif.
endform. "eventtab_build
Form : top_of_page
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
I_LOGO = 'ENJOYSAP_LOGO'
it_list_commentary = g_list_top_of_page.
endform.
Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Company Code
clear t001.
if not p_bukrs is initial.
select single bukrs
into t001-bukrs
from t001
where bukrs eq p_bukrs.
if sy-subrc <> 0.
message e899 with 'Enter Valid Company Code'(012).
endif.
endif.
Validation of GL Account (GR/IR)
clear ska1.
if not p_grira is initial.
select saknr
into ska1-saknr
from ska1
up to 1 rows
where saknr eq p_grira.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid GR/IR Account'(013).
endif.
endif.
Validation of Vendor Code
clear lfa1.
if not s_lifnr[] is initial.
select single lifnr
into lfa1-lifnr
from lfa1
where lifnr in s_lifnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Vendor'(001).
endif.
endif.
Validation of Plant Code
clear t001w.
if not s_werks[] is initial.
select single werks
into t001w-werks
from t001w
where werks in s_werks.
if sy-subrc <> 0.
message e899 with 'Enter Valid Plant'(014).
endif.
endif.
Validation of Material Code
clear mara.
if not s_matnr[] is initial.
select single matnr
into mara-matnr
from mara
where matnr in s_matnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Material'(015).
endif.
endif.
Validation of Purchase Order
clear ekko.
if not s_ebeln[] is initial.
select single ebeln
into ekko-ebeln
from ekko
where ebeln in s_ebeln.
if sy-subrc <> 0.
message e899 with 'Enter Valid Purchase Order'(016).
endif.
endif.
Validation of Cost Center
clear csks.
if not s_kostl[] is initial.
select kostl
into csks-kostl
from csks
up to 1 rows
where kostl in s_kostl.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Center'(017).
endif.
endif.
Validation of Cost Element
clear cska.
if not s_kstar[] is initial.
select kstar
into cska-kstar
from cska
up to 1 rows
where kstar in s_kstar.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Element'(018).
endif.
endif.
endform. "validate_screen
*& Form read_data
Read the Data from the database Tables
form read_data.
Get the Accounting Documents for the GR/IR Account Entered on
Selection Screen
clear i_bsis.
refresh i_bsis.
select bukrs " Company Code
hkont " GR IR Account
gjahr " Fiscal Year
belnr " Acc Document
buzei " Item No
budat " Receipt Date(Posting)
monat " Period
into table i_bsis
from bsis
where bukrs = p_bukrs
and hkont = p_grira
and budat in s_budat
and monat in s_monat .
if sy-subrc <> 0.
message i899 with 'No data found'(043).
g_exit = c_x.
stop.
endif.
sort i_bsis by bukrs hkont gjahr belnr buzei.
Get the Vendor,PO,Material,Qty details from BSEG Table
if not i_bsis[] is initial.
clear i_bseg.
refresh i_bseg.
select bukrs " Company Code
belnr " Acc Document
buzei " Item No
gjahr " Fiscal Year
shkzg " Dr/Cr Indicator
lifnr " Vendor Code
matnr " Material No
ebeln " Purchase Order
ebelp " PO Item
werks " Plant
menge " PO Quantity
meins " UOM
dmbtr " Amount in Local Currency
wrbtr " Amount in Trans.Currency
into table i_bseg
from bseg
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr
and buzei = i_bsis-buzei
and lifnr in s_lifnr
and werks in s_werks
and matnr in s_matnr
and ebeln in s_ebeln.
sort i_bseg by bukrs belnr buzei gjahr.
Select the Trans.Currency from BKPF Table
clear i_bkpf.
refresh i_bkpf.
select bukrs " Company Code
belnr " Acc Document
gjahr " Fiscal Year
waers " Trans. Currency
awkey " Object Key
awtyp " Reference Procedure
into table i_bkpf
from bkpf
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr.
endif.
sort i_bkpf by bukrs belnr gjahr.
Get the Quantity and UOM of Material from MSEG Table
if not i_bkpf[] is initial.
clear i_mseg.
refresh i_mseg.
select mblnr " Material Document
mjahr " Fiscal Year
bwart " Movement Type
matnr " Material No
menge " PO Quantity
meins " UOM
into table i_mseg
from mseg
for all entries in i_bkpf
where mblnr = i_bkpf-awkey(10).
endif.
sort i_mseg by mblnr mjahr.
Get the Material And Description from EKPO Table
if not i_bseg[] is initial.
clear i_ekpo.
refresh i_ekpo.
select ebeln " Purchase Order
ebelp " PO Item
matnr " Material No
txz01 " Material Text
into table i_ekpo
from ekpo
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp.
sort i_ekpo by ebeln ebelp.
Get the Valuation Class from MBEW Table
clear i_mbew.
refresh i_mbew.
select matnr " Material No
bwkey " Plant
bklas " Valuation Class
into table i_mbew
from mbew
for all entries in i_bseg
where matnr = i_bseg-matnr
and bwkey = i_bseg-werks.
sort i_mbew by matnr werks.
Get the Cost Center and Cost Element of the PO from EKKN Table
clear i_ekkn.
refresh i_ekkn.
select ebeln " Purchase Order
ebelp " PO Item
kostl " Cost Center
sakto " Cost Element
into table i_ekkn
from ekkn
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp
and kostl in s_kostl
and sakto in s_kstar.
sort i_ekkn by ebeln ebelp.
Get the Vendor Name
clear i_lfa1.
refresh i_lfa1.
select lifnr " Vendor
name1 " Name
into table i_lfa1
from lfa1
for all entries in i_bseg
where lifnr = i_bseg-lifnr.
endif.
sort i_lfa1 by lifnr.
Move the data to Final Output Internal Table
loop at i_bsis.
i_final-belnr = i_bsis-belnr. " FI Document
i_final-monat = i_bsis-monat. " Period
i_final-budat = i_bsis-budat. " Rec. Date
Read the Transaction Currency from BKPF Internal Table
read table i_bkpf with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
binary search.
if sy-subrc = 0.
i_final-waers = i_bkpf-waers. " Tran.Currency
Read the Movement Type for all Material Related
Documents from MSEG Internal Table
if i_bkpf-awtyp = c_mkpf.
read table i_mseg with key mblnr = i_bkpf-awkey(10)
mjahr = i_bkpf-awkey+10(4).
if sy-subrc = 0.
i_final-bwart = i_mseg-bwart. " Movement Type
endif.
endif.
endif.
Read Vendor, Plant, PO Document, Local And Trans.Amounts
from BSEG Internal Table
read table i_bseg with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
buzei = i_bsis-buzei
binary search.
if sy-subrc = 0.
i_final-lifnr = i_bseg-lifnr. " Vendor
i_final-werks = i_bseg-werks. " Plant
i_final-ebeln = i_bseg-ebeln. " PO
i_final-dmbtr = i_bseg-dmbtr. " Local Amount
i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount
i_final-menge = i_bseg-menge. " Quantity
i_final-meins = i_bseg-meins. " UOM
For Credit Indicator(SHKZG = H) amounts should be (-)ve
if i_bseg-shkzg = c_h.
i_final-dmbtr = i_final-dmbtr * -1.
i_final-wrbtr = i_final-wrbtr * -1.
i_final-menge = i_final-menge * -1.
endif.
Read the Material and its Description from EKPO Internal Table
read table i_ekpo with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
matnr = i_bseg-matnr
binary search.
if sy-subrc = 0.
i_final-matnr = i_ekpo-matnr. " Material Number
i_final-txz01 = i_ekpo-txz01. " Material Text
Populate the Material Status depending on the Input Checkbox
On Selection Screen
if not i_ekpo-matnr is initial.
i_final-status = c_x.
endif.
endif.
Read the PO related Cost Element and Cost Centers
from EKKN Internal Table
read table i_ekkn with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
binary search.
if sy-subrc = 0.
i_final-kostl = i_ekkn-kostl. " Cost Center
i_final-sakto = i_ekkn-sakto. " Cost Element
endif.
Read the Valuation Class from MBEW Internal Table
read table i_mbew with key matnr = i_bseg-matnr
werks = i_bseg-werks
binary search.
if sy-subrc = 0.
i_final-bklas = i_mbew-bklas. " Val Class
endif.
Read the Vendor Name from LFA1 Internal Table
read table i_lfa1 with key lifnr = i_bseg-lifnr
binary search.
if sy-subrc = 0.
i_final-name1 = i_lfa1-name1. " Vendor Name
endif.
endif.
append i_final.
clear i_final.
endloop.
sort i_final by lifnr werks monat matnr.
Depending on the check Box Selected display the data
if p_incmt = c_x and p_incnm ne c_x.
delete i_final where matnr eq space.
elseif p_incnm = c_x and p_incmt ne c_x.
delete i_final where matnr ne space.
endif.
endform. "Read Data
Form : populate_layout_stucture
Description : Populating the layout structure
form populate_layout_stucture.
clear x_layout .
Layout properties
x_layout-zebra = c_x.
x_layout-detail_popup = c_x.
x_layout-detail_initial_lines = c_x.
x_layout-colwidth_optimize = c_x.
endform. " populate_layout_stucture
Form : build_field_catalog
Description : Building the field catalog data
form build_field_catalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = g_repid
i_internal_tabname = 'I_FINAL'
i_inclname = g_repid
changing
ct_fieldcat = i_fldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Getting the Header text for the coloums
loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
fieldname = 'NAME1' or
fieldname = 'WERKS' or
fieldname = 'MONAT' or
fieldname = 'MATNR' or
fieldname = 'BKLAS' or
fieldname = 'EBELN' or
fieldname = 'KOSTL' or
fieldname = 'SAKTO' or
fieldname = 'BUDAT' or
fieldname = 'BELNR' or
fieldname = 'BWART' or
fieldname = 'TXZ01' or
fieldname = 'MENGE' or
fieldname = 'MEINS' or
fieldname = 'DMBTR' or
fieldname = 'WRBTR' or
fieldname = 'WAERS' or
fieldname = 'STATUS'.
if x_fldcat-fieldname = 'LIFNR'.
x_fldcat-seltext_l = 'Vendor'(003).
x_fldcat-seltext_m = 'Vendor'(003).
x_fldcat-seltext_s = 'Vendor'(003).
x_fldcat-reptext_ddic = 'Vendor'(003).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'NAME1'.
x_fldcat-seltext_l = 'Vendor Name'(002).
x_fldcat-seltext_m = 'Vendor Name'(002).
x_fldcat-seltext_s = 'Vendor Name'(002).
x_fldcat-reptext_ddic = 'Vendor Name'(002).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'WERKS'.
x_fldcat-seltext_l = 'Plant'(010).
x_fldcat-seltext_m = 'Plant'(010).
x_fldcat-seltext_s = 'Plant'(010).
x_fldcat-reptext_ddic = 'Plant'(010).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MONAT'.
x_fldcat-seltext_l = 'Period'(011).
x_fldcat-seltext_m = 'Period'(011).
x_fldcat-seltext_s = 'Period'(011).
x_fldcat-reptext_ddic = 'Period'(011).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MATNR'.
x_fldcat-seltext_l = 'Material'(004).
x_fldcat-seltext_m = 'Material'(004).
x_fldcat-seltext_s = 'Material'(004).
x_fldcat-reptext_ddic = 'Material'(004).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BKLAS'.
x_fldcat-seltext_l = 'Valuation Class'(009).
x_fldcat-seltext_m = 'Valuation Class'(009).
x_fldcat-seltext_s = 'Valuation Class'(009).
x_fldcat-reptext_ddic = 'Valuation Class'(009).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'EBELN'.
x_fldcat-seltext_l = 'Purchase Order'(005).
x_fldcat-seltext_m = 'Purchase Order'(005).
x_fldcat-seltext_s = 'Purchase Order'(005).
x_fldcat-reptext_ddic = 'Purchase Order'(005).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'KOSTL'.
x_fldcat-seltext_l = 'Cost Center'(006).
x_fldcat-seltext_m = 'Cost Center'(006).
x_fldcat-seltext_s = 'Cost Center'(006).
x_fldcat-reptext_ddic = 'Cost Center'(006).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'SAKTO'.
x_fldcat-seltext_l = 'Cost Element'(007).
x_fldcat-seltext_m = 'Cost Element'(007).
x_fldcat-seltext_s = 'Cost Element'(007).
x_fldcat-reptext_ddic = 'Cost Element'(007).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BUDAT'.
x_fldcat-seltext_l = 'Receipt Date'(008).
x_fldcat-seltext_m = 'Receipt Date'(008).
x_fldcat-seltext_s = 'Receipt Date'(008).
x_fldcat-reptext_ddic = 'Receipt Date'(008).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BELNR'.
x_fldcat-seltext_l = 'Acc.Document'(100).
x_fldcat-seltext_m = 'Acc.Document'(100).
x_fldcat-seltext_s = 'Acc.Document'(100).
x_fldcat-reptext_ddic = 'Acc.Document'(100).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BWART'.
x_fldcat-seltext_l = 'Movement Type'(101).
x_fldcat-seltext_m = 'Movement Type'(101).
x_fldcat-seltext_s = 'Movement Type'(101).
x_fldcat-reptext_ddic = 'Movement Type'(101).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'TXZ01'.
x_fldcat-seltext_l = 'Material Text'(102).
x_fldcat-seltext_m = 'Material Text'(102).
x_fldcat-seltext_s = 'Material Text'(102).
x_fldcat-reptext_ddic = 'Material Text'(102).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE'.
x_fldcat-seltext_l = 'Quantity'(103).
x_fldcat-seltext_m = 'Quantity'(103).
x_fldcat-seltext_s = 'Quantity'(103).
x_fldcat-reptext_ddic = 'Quantity'(103).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'(104).
x_fldcat-seltext_m = 'UOM'(104).
x_fldcat-seltext_s = 'UOM'(104).
x_fldcat-reptext_ddic = 'UOM'(104).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'DMBTR'.
x_fldcat-seltext_l = 'Amount in Local Curr'(105).
x_fldcat-seltext_m = 'Amount in Local Curr'(105).
x_fldcat-seltext_s = 'Amount in Local Curr'(105).
x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WRBTR'.
x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).
x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WAERS'.
x_fldcat-seltext_l = 'Trans.Currency'(107).
x_fldcat-seltext_m = 'Trans.Currency'(107).
x_fldcat-seltext_s = 'Trans.Currency'(107).
x_fldcat-reptext_ddic = 'Trans.Currency'(107).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'STATUS'.
x_fldcat-seltext_l = 'Material Status'(019).
x_fldcat-seltext_m = 'Material Status'(019).
x_fldcat-seltext_s = 'Material Status'(019).
x_fldcat-reptext_ddic = 'Material Status'(019).
x_fldcat-ddictxt = c_l.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
endloop.
endform. " build_field_catalog
Form : build_sort_totals
Description : Building the Criteria for Sort/Subtotals
form build_sort_totals.
x_sort-fieldname = 'LIFNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WERKS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 3.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MATNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 4.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BKLAS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 5.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'EBELN'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 6.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'KOSTL'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 7.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'SAKTO'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 8.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BUDAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 9.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
endform. " build_sort_totals
Form : comment_build
Description : This form is used to display the Report Header(ALV)
form comment_build using lt_top_of_page type
slis_t_listheader.
data: l_line type slis_listheader,
l_heading1 like rs38m-repti,
l_date(10), l_time(8).
clear l_line.
l_heading1 = 'GR/IR DETAIL REPORT'(021).
g_repid = sy-repid.
write sy-uzeit to l_time.
write sy-datum to l_date.
l_line-typ = c_h.
move l_heading1 to l_line-info.
append l_line to lt_top_of_page.
clear l_line.
l_line-typ = c_s.
concatenate 'System:'(023) sy-sysid
'Date:'(024) l_date
' Time:'(025)
l_time into l_line-info.
append l_line to lt_top_of_page.
concatenate 'Report:'(026) g_repid
' User:'(027) sy-uname into
l_line-info.
append l_line to lt_top_of_page.
l_line-typ = c_a.
move 'SELECTION CRITERIA:'(028) to l_line-info.
append l_line to lt_top_of_page.
concatenate ' Company Code : '(029)
p_bukrs into l_line-info.
append l_line to lt_top_of_page.
concatenate ' GR/IR Account: '(030)
p_grira into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Posting Date : '(032) s_budat-low
' To: '(031) s_budat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Plant : '(033) s_werks-low
' To: '(031) s_werks-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Vendor: '(034) s_lifnr-low
' To: '(031) s_lifnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Material: '(035) s_matnr-low
' To: '(031) s_matnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Center : '(036) s_kostl-low
' To: '(031) s_kostl-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Element: '(037) s_kstar-low
' To: '(031) s_kstar-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Purchase Order: '(038) s_ebeln-low
' To: '(031) s_ebeln-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Period : '(039) s_monat-low
' To: '(031) s_monat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Material Items: '(040)
p_incmt into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Non-Material Items: '(041)
p_incnm into l_line-info.
append l_line to lt_top_of_page.
endform.
Form : call_list_viewer
Description : This form is used to display the grid through ALV
form call_list_viewer.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = x_layout
it_fieldcat = i_fldcat[]
i_default = c_x
it_sort = i_sort[]
i_save = g_save
is_variant = g_variant
it_events = g_events[]
importing
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = g_exit_caused_by_user
tables
t_outtab = i_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
write: / 'Problem in calling the ALV report'(042).
endif.
endform. " call_list_viewer
Regards
Anji -
Need Report for gross profit anaylsis for the month
Hi gurus,
i need this report coding as the client has not provided me much information regarding this.selection screen.Company code ,plant code,materialcode,material type,period,fiscal year.this report format should be in alv .
Sp pls send me the coding for this.
Urs
pradeepCheck below transaction codes and it may be useful
Customer Analysis- Sales - MC+E
Customer Analysis- Cr. Memo - MC+I
Deliveries-Due list - VL04
Billing due list - VF04
Incomplete Billing documents - MCV9
Customer Analysis-Basic List - MCTA
Material Analysis(SIS) - MCTC
Sales org analysis - MCTE
Sales org analysis-Invoiced sales - MC+2
Material Analysis-Incoming orders - MC(E
General- List of Outbound deliveries - VL06f
Material Returns-Analysis - MC+M
Material Analysis- Invoiced Sales - MC+Q
Thanks
Seshu -
Query performance after patch upgrade
Hi All,
We were earlier on SP17 and then upgraded recently to SP23. It was after this that we started noticing few anomalies. This includes really long runtime to run queries (more than 2 hours). This earlier (before upgrade) used to run in hardly 2 mins for the same selection criteria. This happens with majority of queries.
Let me elaborate this a little further. I have a very important sales query which is being used by many endusers all across India. This query has the following parameters as the selection screen. -
a) Division (mandatory)
b) Plant (mandatory)
c) Sales Office (mandatory)
d) Material (optional)
e) Fiscal year period range : <Starting Fiscal period> to <Ending Fiscal Period> (Mandatory)
Usually this report is run for 4 & 5 series materials. Hence normally users enter the following criteria while running this query-
Division - 03
Plant - L501
Sales Office - L003
Material - 400000 to 599999
Fiscal Year period range : YTD Range.
To run this report it takes more than 2 hours. Now say for instance this report is run and it brings in 50 materials. I export the list of these 50 materials and then run the same query again for the same criteria except this time, I execute the report not for material range of 4 & 5 Series but only for these 50 materials specifically. This then takes 2 Mins.
The problem is that we cannot expect all the users to do this. Has anybody faced this issue earlier. I request assistance in resolving this problem.
Regards,
SreeOne further observation.
When the report is not executed for any material (i.e. the material values are kept blank in the selection screen itself), then the report runs in like 2 mins again (the other parameters are kept the same as mentioned in the above message).
Can anyone put some light into this.
Regards,
Sree -
Sorting criteria not validating in Z Programe development
We are in process of data fatching in a Z development program and faced with following situation;
1. We pass criteria as Fiscal Year 2010 and posting date as 01.04.2010 to 30.04.2010
2. Accourding to above input we fatch data in MSEG table
3. But when passing the MSEG reference field into header table MKPF we find different date (i.e. October 2010) which is different from initial data range (i.e. April 2010)
It seems that we are unable to put date check criteria,
How could we initiate the date check successfully. Kindly suggest.
Regards
MayoorSir ;
we seek your Guidance within Following Criteria :
1.) we r under the process of sorting data having material movement with Financial Impects
2.) how to sort data from the related tables since we have two year's that is Material year and fiscal year.
3.) we desire to sort data specific to particular date range with in one Period
Plz. advice. -
Hi All,
Can any one let me know how to build fieldcat for ALV using OOPS.
thanks.
KhanHi
see the sample program for the Reuse_ALV_FIELD_CATALOG_MERGE and do accordingly
report ZRGRIRNA no standard page heading
line-count 65
line-size 255
message-id mm.
GR IR Detail Report *
Description : The output has to be displayed
in the ALV Grid format with the Selection *
screen appearing on the output. In The Output *
Subtotals for Vendor, Plant, Period, Material,*
Valuation Class, Purchase Order,Cost Center, *
Cost Element and Receipt Date are displayed *
after sorting the data by same fields. *
Declaration for Tables
tables: t001, " Company Codes
t001w, " Plants/Branches
lfa1, " Vendor Master
ska1, " GL Account Master
mara, " Material Master
mbew, " Material Valuation
ekko, " PO Header Data
cska, " Cost Elements
csks, " Cost Centers
bsis, " GL Accounts: Open Items Data
bkpf. " Accounting Doc: Header Data
Type-pools
Type pools for ALV display
type-pools : slis.
Global variables
data: g_repid like sy-repid,
g_exit type c,
g_events type slis_t_event,
g_list_top_of_page type slis_t_listheader,
g_exit_caused_by_caller,
g_exit_caused_by_user type slis_exit_by_user,
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_variant like disvariant,
g_save.
Declaration for Constants
constants : c_x type c value 'X', " Flag
c_c type c value 'C', " Flag
c_l type c value 'L', " Flag
c_a type c value 'A', " Line Type
c_h type c value 'H', " Dr/Cr
c_s type c value 'S', " Line Type
c_mkpf(4) type c value 'MKPF'. " Table
Declaration of Internal Tables
Internal Table for BSIS Table data
data: begin of i_bsis occurs 0,
bukrs like bsis-bukrs, " Company Code
hkont like bsis-hkont, " GR IR Account
gjahr like bsis-gjahr, " Fiscal Year
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
budat like bsis-budat, " Receipt Date(Posting)
monat like bsis-monat, " Period
end of i_bsis.
Internal Table for BSEG Table data
data: begin of i_bseg occurs 0,
bukrs like bsis-bukrs, " Company Code
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
gjahr like bsis-gjahr, " Fiscal Year
shkzg like bseg-shkzg, " Dr/Cr Indicator
lifnr like bseg-lifnr, " Vendor Code
matnr like bseg-matnr, " Material No
ebeln like bseg-ebeln, " Purchase Order
ebelp like bseg-ebelp, " PO Item
werks like bseg-werks, " Plant
menge like bseg-menge, " PO Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Amount in Local Currency
wrbtr like bseg-wrbtr, " Amount in Trans.Currency
end of i_bseg.
Internal Table for BKPF Table data
data: begin of i_bkpf occurs 0,
bukrs like bkpf-bukrs, " Company Code
belnr like bkpf-belnr, " Acc Document
gjahr like bkpf-gjahr, " Fiscal Year
waers like bkpf-waers, " Trans. Currency
awkey like bkpf-awkey, " Object Key
awtyp like bkpf-awtyp, " Reference Procedure
end of i_bkpf.
Internal Table for MSEG Table data
data: begin of i_mseg occurs 0,
mblnr like mseg-mblnr, " Material Document
mjahr like mseg-mjahr, " Fiscal Year
bwart like mseg-bwart, " Movement Type
matnr like mseg-matnr, " Material No
menge like mseg-menge, " PO Quantity
meins like mseg-meins, " UOM
end of i_mseg.
Internal Table for MBEW Table data
data: begin of i_mbew occurs 0,
matnr like mbew-matnr, " Material No
werks like mbew-bwkey, " Plant
bklas like mbew-bklas, " Valuation Class
end of i_mbew.
Internal Table for EKPO Table data
data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln, " Purchase Order
ebelp like ekpo-ebelp, " PO Item
matnr like ekpo-matnr, " Material No
txz01 like ekpo-txz01, " Material Text
end of i_ekpo.
Internal Table for EKKN Table data
data: begin of i_ekkn occurs 0,
ebeln like ekkn-ebeln, " Purchase Order
ebelp like ekkn-ebelp, " PO Item
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
end of i_ekkn.
Internal Table for LFA1 Table data
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, " Vendor
name1 like lfa1-name1, " Name
end of i_lfa1.
Declaration of Output Internal Table
data: begin of i_final occurs 0,
lifnr like lfa1-lifnr, " Vendor
werks like bseg-werks, " Plant
monat like bsis-monat, " Period
matnr like mara-matnr, " Material Number
bklas like mbew-bklas, " Val Class
ebeln like bseg-ebeln, " PO
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
budat like bsis-budat, " Rec. Date
name1 like lfa1-name1, " Vendor Name
belnr like bsis-belnr, " FI Document
bwart like mseg-bwart, " Movement Type
txz01 like ekpo-txz01, " Material Text
menge like bseg-menge, " Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Local Amount
wrbtr like bseg-wrbtr, " Tran.Amount
waers like bkpf-waers, " Tran.Currency
status type c, " Material Status
end of i_final.
Internal table to hold field catgory data
data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
Structure
data: x_layout type slis_layout_alv, " Structure-layout
x_fldcat like line of i_fldcat, " Structure-field catagory
x_sort like line of i_sort. " Structure-Sort/Subtotals
Selection screen
selection-screen : begin of block b1 with frame title text-000.
parameters:
p_bukrs like t001-bukrs obligatory, " Company Code
p_grira like ska1-saknr default '0241101000' obligatory. " Account
select-options:
s_budat for bkpf-budat, " Posting Date
s_werks for t001w-werks, " Plant
s_lifnr for lfa1-lifnr, " Vendor
s_matnr for mara-matnr, " Material Number
s_kostl for csks-kostl, " Cost Center
s_kstar for cska-kstar, " Cost Element
s_ebeln for ekko-ebeln, " Purchase Order
s_monat for bsis-monat. " Period
selection-screen skip.
parameters:
p_incmt as checkbox default 'X',
p_incnm as checkbox default 'X'.
selection-screen end of block b1.
Initialization
initialization.
g_repid = sy-repid.
perform layout_init using x_layout.
perform eventtab_build using g_events[].
g_variant-report = g_repid.
g_save = 'A'.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
perform validate_screen.
Start of selection
start-of-selection.
Read Data from Database Tables
perform read_data.
End of selection
end-of-selection.
Build layout report layout.
perform populate_layout_stucture.
Perform build_field_catalog and Sort Table
perform build_field_catalog.
perform build_sort_totals.
List Header for Top-Of-Page
perform comment_build using g_list_top_of_page[].
Call list viewer function module
perform call_list_viewer .
****************Form - Routines**************************************
Form : layout_init
Description : Form to Build layout for list display
form layout_init using rs_layout type slis_layout_alv.
rs_layout-detail_popup = c_x.
endform.
Form : Eventtab_build
Description : Registration of events to happen during list display
form eventtab_build using rt_events type slis_t_event.
Registration of events to happen during list display
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = rt_events.
read table rt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move g_top_of_page to ls_event-form.
append ls_event to rt_events.
endif.
endform. "eventtab_build
Form : top_of_page
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
I_LOGO = 'ENJOYSAP_LOGO'
it_list_commentary = g_list_top_of_page.
endform.
Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Company Code
clear t001.
if not p_bukrs is initial.
select single bukrs
into t001-bukrs
from t001
where bukrs eq p_bukrs.
if sy-subrc <> 0.
message e899 with 'Enter Valid Company Code'(012).
endif.
endif.
Validation of GL Account (GR/IR)
clear ska1.
if not p_grira is initial.
select saknr
into ska1-saknr
from ska1
up to 1 rows
where saknr eq p_grira.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid GR/IR Account'(013).
endif.
endif.
Validation of Vendor Code
clear lfa1.
if not s_lifnr[] is initial.
select single lifnr
into lfa1-lifnr
from lfa1
where lifnr in s_lifnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Vendor'(001).
endif.
endif.
Validation of Plant Code
clear t001w.
if not s_werks[] is initial.
select single werks
into t001w-werks
from t001w
where werks in s_werks.
if sy-subrc <> 0.
message e899 with 'Enter Valid Plant'(014).
endif.
endif.
Validation of Material Code
clear mara.
if not s_matnr[] is initial.
select single matnr
into mara-matnr
from mara
where matnr in s_matnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Material'(015).
endif.
endif.
Validation of Purchase Order
clear ekko.
if not s_ebeln[] is initial.
select single ebeln
into ekko-ebeln
from ekko
where ebeln in s_ebeln.
if sy-subrc <> 0.
message e899 with 'Enter Valid Purchase Order'(016).
endif.
endif.
Validation of Cost Center
clear csks.
if not s_kostl[] is initial.
select kostl
into csks-kostl
from csks
up to 1 rows
where kostl in s_kostl.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Center'(017).
endif.
endif.
Validation of Cost Element
clear cska.
if not s_kstar[] is initial.
select kstar
into cska-kstar
from cska
up to 1 rows
where kstar in s_kstar.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Element'(018).
endif.
endif.
endform. "validate_screen
*& Form read_data
Read the Data from the database Tables
form read_data.
Get the Accounting Documents for the GR/IR Account Entered on
Selection Screen
clear i_bsis.
refresh i_bsis.
select bukrs " Company Code
hkont " GR IR Account
gjahr " Fiscal Year
belnr " Acc Document
buzei " Item No
budat " Receipt Date(Posting)
monat " Period
into table i_bsis
from bsis
where bukrs = p_bukrs
and hkont = p_grira
and budat in s_budat
and monat in s_monat .
if sy-subrc <> 0.
message i899 with 'No data found'(043).
g_exit = c_x.
stop.
endif.
sort i_bsis by bukrs hkont gjahr belnr buzei.
Get the Vendor,PO,Material,Qty details from BSEG Table
if not i_bsis[] is initial.
clear i_bseg.
refresh i_bseg.
select bukrs " Company Code
belnr " Acc Document
buzei " Item No
gjahr " Fiscal Year
shkzg " Dr/Cr Indicator
lifnr " Vendor Code
matnr " Material No
ebeln " Purchase Order
ebelp " PO Item
werks " Plant
menge " PO Quantity
meins " UOM
dmbtr " Amount in Local Currency
wrbtr " Amount in Trans.Currency
into table i_bseg
from bseg
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr
and buzei = i_bsis-buzei
and lifnr in s_lifnr
and werks in s_werks
and matnr in s_matnr
and ebeln in s_ebeln.
sort i_bseg by bukrs belnr buzei gjahr.
Select the Trans.Currency from BKPF Table
clear i_bkpf.
refresh i_bkpf.
select bukrs " Company Code
belnr " Acc Document
gjahr " Fiscal Year
waers " Trans. Currency
awkey " Object Key
awtyp " Reference Procedure
into table i_bkpf
from bkpf
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr.
endif.
sort i_bkpf by bukrs belnr gjahr.
Get the Quantity and UOM of Material from MSEG Table
if not i_bkpf[] is initial.
clear i_mseg.
refresh i_mseg.
select mblnr " Material Document
mjahr " Fiscal Year
bwart " Movement Type
matnr " Material No
menge " PO Quantity
meins " UOM
into table i_mseg
from mseg
for all entries in i_bkpf
where mblnr = i_bkpf-awkey(10).
endif.
sort i_mseg by mblnr mjahr.
Get the Material And Description from EKPO Table
if not i_bseg[] is initial.
clear i_ekpo.
refresh i_ekpo.
select ebeln " Purchase Order
ebelp " PO Item
matnr " Material No
txz01 " Material Text
into table i_ekpo
from ekpo
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp.
sort i_ekpo by ebeln ebelp.
Get the Valuation Class from MBEW Table
clear i_mbew.
refresh i_mbew.
select matnr " Material No
bwkey " Plant
bklas " Valuation Class
into table i_mbew
from mbew
for all entries in i_bseg
where matnr = i_bseg-matnr
and bwkey = i_bseg-werks.
sort i_mbew by matnr werks.
Get the Cost Center and Cost Element of the PO from EKKN Table
clear i_ekkn.
refresh i_ekkn.
select ebeln " Purchase Order
ebelp " PO Item
kostl " Cost Center
sakto " Cost Element
into table i_ekkn
from ekkn
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp
and kostl in s_kostl
and sakto in s_kstar.
sort i_ekkn by ebeln ebelp.
Get the Vendor Name
clear i_lfa1.
refresh i_lfa1.
select lifnr " Vendor
name1 " Name
into table i_lfa1
from lfa1
for all entries in i_bseg
where lifnr = i_bseg-lifnr.
endif.
sort i_lfa1 by lifnr.
Move the data to Final Output Internal Table
loop at i_bsis.
i_final-belnr = i_bsis-belnr. " FI Document
i_final-monat = i_bsis-monat. " Period
i_final-budat = i_bsis-budat. " Rec. Date
Read the Transaction Currency from BKPF Internal Table
read table i_bkpf with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
binary search.
if sy-subrc = 0.
i_final-waers = i_bkpf-waers. " Tran.Currency
Read the Movement Type for all Material Related
Documents from MSEG Internal Table
if i_bkpf-awtyp = c_mkpf.
read table i_mseg with key mblnr = i_bkpf-awkey(10)
mjahr = i_bkpf-awkey+10(4).
if sy-subrc = 0.
i_final-bwart = i_mseg-bwart. " Movement Type
endif.
endif.
endif.
Read Vendor, Plant, PO Document, Local And Trans.Amounts
from BSEG Internal Table
read table i_bseg with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
buzei = i_bsis-buzei
binary search.
if sy-subrc = 0.
i_final-lifnr = i_bseg-lifnr. " Vendor
i_final-werks = i_bseg-werks. " Plant
i_final-ebeln = i_bseg-ebeln. " PO
i_final-dmbtr = i_bseg-dmbtr. " Local Amount
i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount
i_final-menge = i_bseg-menge. " Quantity
i_final-meins = i_bseg-meins. " UOM
For Credit Indicator(SHKZG = H) amounts should be (-)ve
if i_bseg-shkzg = c_h.
i_final-dmbtr = i_final-dmbtr * -1.
i_final-wrbtr = i_final-wrbtr * -1.
i_final-menge = i_final-menge * -1.
endif.
Read the Material and its Description from EKPO Internal Table
read table i_ekpo with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
matnr = i_bseg-matnr
binary search.
if sy-subrc = 0.
i_final-matnr = i_ekpo-matnr. " Material Number
i_final-txz01 = i_ekpo-txz01. " Material Text
Populate the Material Status depending on the Input Checkbox
On Selection Screen
if not i_ekpo-matnr is initial.
i_final-status = c_x.
endif.
endif.
Read the PO related Cost Element and Cost Centers
from EKKN Internal Table
read table i_ekkn with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
binary search.
if sy-subrc = 0.
i_final-kostl = i_ekkn-kostl. " Cost Center
i_final-sakto = i_ekkn-sakto. " Cost Element
endif.
Read the Valuation Class from MBEW Internal Table
read table i_mbew with key matnr = i_bseg-matnr
werks = i_bseg-werks
binary search.
if sy-subrc = 0.
i_final-bklas = i_mbew-bklas. " Val Class
endif.
Read the Vendor Name from LFA1 Internal Table
read table i_lfa1 with key lifnr = i_bseg-lifnr
binary search.
if sy-subrc = 0.
i_final-name1 = i_lfa1-name1. " Vendor Name
endif.
endif.
append i_final.
clear i_final.
endloop.
sort i_final by lifnr werks monat matnr.
Depending on the check Box Selected display the data
if p_incmt = c_x and p_incnm ne c_x.
delete i_final where matnr eq space.
elseif p_incnm = c_x and p_incmt ne c_x.
delete i_final where matnr ne space.
endif.
endform. "Read Data
Form : populate_layout_stucture
Description : Populating the layout structure
form populate_layout_stucture.
clear x_layout .
Layout properties
x_layout-zebra = c_x.
x_layout-detail_popup = c_x.
x_layout-detail_initial_lines = c_x.
x_layout-colwidth_optimize = c_x.
endform. " populate_layout_stucture
Form : build_field_catalog
Description : Building the field catalog data
form build_field_catalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = g_repid
i_internal_tabname = 'I_FINAL'
i_inclname = g_repid
changing
ct_fieldcat = i_fldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Getting the Header text for the coloums
loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
fieldname = 'NAME1' or
fieldname = 'WERKS' or
fieldname = 'MONAT' or
fieldname = 'MATNR' or
fieldname = 'BKLAS' or
fieldname = 'EBELN' or
fieldname = 'KOSTL' or
fieldname = 'SAKTO' or
fieldname = 'BUDAT' or
fieldname = 'BELNR' or
fieldname = 'BWART' or
fieldname = 'TXZ01' or
fieldname = 'MENGE' or
fieldname = 'MEINS' or
fieldname = 'DMBTR' or
fieldname = 'WRBTR' or
fieldname = 'WAERS' or
fieldname = 'STATUS'.
if x_fldcat-fieldname = 'LIFNR'.
x_fldcat-seltext_l = 'Vendor'(003).
x_fldcat-seltext_m = 'Vendor'(003).
x_fldcat-seltext_s = 'Vendor'(003).
x_fldcat-reptext_ddic = 'Vendor'(003).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'NAME1'.
x_fldcat-seltext_l = 'Vendor Name'(002).
x_fldcat-seltext_m = 'Vendor Name'(002).
x_fldcat-seltext_s = 'Vendor Name'(002).
x_fldcat-reptext_ddic = 'Vendor Name'(002).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'WERKS'.
x_fldcat-seltext_l = 'Plant'(010).
x_fldcat-seltext_m = 'Plant'(010).
x_fldcat-seltext_s = 'Plant'(010).
x_fldcat-reptext_ddic = 'Plant'(010).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MONAT'.
x_fldcat-seltext_l = 'Period'(011).
x_fldcat-seltext_m = 'Period'(011).
x_fldcat-seltext_s = 'Period'(011).
x_fldcat-reptext_ddic = 'Period'(011).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MATNR'.
x_fldcat-seltext_l = 'Material'(004).
x_fldcat-seltext_m = 'Material'(004).
x_fldcat-seltext_s = 'Material'(004).
x_fldcat-reptext_ddic = 'Material'(004).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BKLAS'.
x_fldcat-seltext_l = 'Valuation Class'(009).
x_fldcat-seltext_m = 'Valuation Class'(009).
x_fldcat-seltext_s = 'Valuation Class'(009).
x_fldcat-reptext_ddic = 'Valuation Class'(009).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'EBELN'.
x_fldcat-seltext_l = 'Purchase Order'(005).
x_fldcat-seltext_m = 'Purchase Order'(005).
x_fldcat-seltext_s = 'Purchase Order'(005).
x_fldcat-reptext_ddic = 'Purchase Order'(005).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'KOSTL'.
x_fldcat-seltext_l = 'Cost Center'(006).
x_fldcat-seltext_m = 'Cost Center'(006).
x_fldcat-seltext_s = 'Cost Center'(006).
x_fldcat-reptext_ddic = 'Cost Center'(006).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'SAKTO'.
x_fldcat-seltext_l = 'Cost Element'(007).
x_fldcat-seltext_m = 'Cost Element'(007).
x_fldcat-seltext_s = 'Cost Element'(007).
x_fldcat-reptext_ddic = 'Cost Element'(007).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BUDAT'.
x_fldcat-seltext_l = 'Receipt Date'(008).
x_fldcat-seltext_m = 'Receipt Date'(008).
x_fldcat-seltext_s = 'Receipt Date'(008).
x_fldcat-reptext_ddic = 'Receipt Date'(008).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BELNR'.
x_fldcat-seltext_l = 'Acc.Document'(100).
x_fldcat-seltext_m = 'Acc.Document'(100).
x_fldcat-seltext_s = 'Acc.Document'(100).
x_fldcat-reptext_ddic = 'Acc.Document'(100).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BWART'.
x_fldcat-seltext_l = 'Movement Type'(101).
x_fldcat-seltext_m = 'Movement Type'(101).
x_fldcat-seltext_s = 'Movement Type'(101).
x_fldcat-reptext_ddic = 'Movement Type'(101).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'TXZ01'.
x_fldcat-seltext_l = 'Material Text'(102).
x_fldcat-seltext_m = 'Material Text'(102).
x_fldcat-seltext_s = 'Material Text'(102).
x_fldcat-reptext_ddic = 'Material Text'(102).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE'.
x_fldcat-seltext_l = 'Quantity'(103).
x_fldcat-seltext_m = 'Quantity'(103).
x_fldcat-seltext_s = 'Quantity'(103).
x_fldcat-reptext_ddic = 'Quantity'(103).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'(104).
x_fldcat-seltext_m = 'UOM'(104).
x_fldcat-seltext_s = 'UOM'(104).
x_fldcat-reptext_ddic = 'UOM'(104).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'DMBTR'.
x_fldcat-seltext_l = 'Amount in Local Curr'(105).
x_fldcat-seltext_m = 'Amount in Local Curr'(105).
x_fldcat-seltext_s = 'Amount in Local Curr'(105).
x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WRBTR'.
x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).
x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WAERS'.
x_fldcat-seltext_l = 'Trans.Currency'(107).
x_fldcat-seltext_m = 'Trans.Currency'(107).
x_fldcat-seltext_s = 'Trans.Currency'(107).
x_fldcat-reptext_ddic = 'Trans.Currency'(107).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'STATUS'.
x_fldcat-seltext_l = 'Material Status'(019).
x_fldcat-seltext_m = 'Material Status'(019).
x_fldcat-seltext_s = 'Material Status'(019).
x_fldcat-reptext_ddic = 'Material Status'(019).
x_fldcat-ddictxt = c_l.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
endloop.
endform. " build_field_catalog
Form : build_sort_totals
Description : Building the Criteria for Sort/Subtotals
form build_sort_totals.
x_sort-fieldname = 'LIFNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WERKS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 3.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MATNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 4.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BKLAS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 5.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'EBELN'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 6.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'KOSTL'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 7.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'SAKTO'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 8.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BUDAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 9.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
endform. " build_sort_totals
Form : comment_build
Description : This form is used to display the Report Header(ALV)
form comment_build using lt_top_of_page type
slis_t_listheader.
data: l_line type slis_listheader,
l_heading1 like rs38m-repti,
l_date(10), l_time(8).
clear l_line.
l_heading1 = 'GR/IR DETAIL REPORT'(021).
g_repid = sy-repid.
write sy-uzeit to l_time.
write sy-datum to l_date.
l_line-typ = c_h.
move l_heading1 to l_line-info.
append l_line to lt_top_of_page.
clear l_line.
l_line-typ = c_s.
concatenate 'System:'(023) sy-sysid
'Date:'(024) l_date
' Time:'(025)
l_time into l_line-info.
append l_line to lt_top_of_page.
concatenate 'Report:'(026) g_repid
' User:'(027) sy-uname into
l_line-info.
append l_line to lt_top_of_page.
l_line-typ = c_a.
move 'SELECTION CRITERIA:'(028) to l_line-info.
append l_line to lt_top_of_page.
concatenate ' Company Code : '(029)
p_bukrs into l_line-info.
append l_line to lt_top_of_page.
concatenate ' GR/IR Account: '(030)
p_grira into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Posting Date : '(032) s_budat-low
' To: '(031) s_budat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Plant : '(033) s_werks-low
' To: '(031) s_werks-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Vendor: '(034) s_lifnr-low
' To: '(031) s_lifnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Material: '(035) s_matnr-low
' To: '(031) s_matnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Center : '(036) s_kostl-low
' To: '(031) s_kostl-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Element: '(037) s_kstar-low
' To: '(031) s_kstar-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Purchase Order: '(038) s_ebeln-low
' To: '(031) s_ebeln-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Period : '(039) s_monat-low
' To: '(031) s_monat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Material Items: '(040)
p_incmt into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Non-Material Items: '(041)
p_incnm into l_line-info.
append l_line to lt_top_of_page.
endform.
Form : call_list_viewer
Description : This form is used to display the grid through ALV
form call_list_viewer.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = x_layout
it_fieldcat = i_fldcat[]
i_default = c_x
it_sort = i_sort[]
i_save = g_save
is_variant = g_variant
it_events = g_events[]
importing
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = g_exit_caused_by_user
tables
t_outtab = i_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
write: / 'Problem in calling the ALV report'(042).
endif.
endform. " call_list_viewer
Regards
anji -
Hi All,
I want to devlop a sales report,
please can any one explain me how to write select and go ahead
the requiremnet is like this
Based on selection criteria
Sales organisation (VBRK-VKORG),
Distribution channel (VBRK-VTWEG),
Division (VBRK_SPART),
Billing date(VBRK-ERDAT),
Customer (VBRK-KUNAG),
plant (VBRP-WERKS), and
Material Group1(VBRP-MVGR1).
Check if VBRK-FKSTO # X, VBRK-RFBSK = C, VBRK-FKART #S1 and S2, take all VBRK-VBELNs (Print in Invoice number ).
VBRK-ERDAT(Print in Invoice Date).
Pass VBRK-VBELN to VBRP-VBELN and check for every VBRP-MVGR1 pass VBRP-POSNR to KONV-KPOSN and
For KONV-KSCHL =ZPTS sum all KONV-KWERT and display(PTS value).
For KONV-KSCHL =YNRV sum all KONV-KWERT and display(NRV Value).
thanks in advacne
points will be rewarded if it is use full
jayHi,
Refer this code.
REPORT z_daily_sales
NO STANDARD PAGE HEADING
MESSAGE-ID sabapdocu.
TABLES *
TABLES : vbak, "Sales Document: Header Data
tfacs, "Factory calendar (display)
vbrk, "Billing: Header Data
vbrp, "Billing: Item Data
vbpa, "Sales Document: Partner
lips, "SD doc: Delivery: Item data
mkpf, "Header: Material Document
mseg, "Document Segment: Material
konv. "Conditions (Trans Data)
CONSTANTS *
CONSTANTS : c_top_of_page(15) TYPE c VALUE 'SUB_TOP_OF_PAGE'.
TYPE-POOL *
TYPE-POOLS : slis. "Global types for generic cunning building blocks
VARIABLES *
DATA : v_repid TYPE sy-repid, "Report ID
v_month(2) TYPE c, "Variable for Month
v_year(4) TYPE c, "Variable for year
v_days(31) TYPE c, "Variable for days
v_ship(10) TYPE c VALUE 0, "Variable for total days
v_jan(31) TYPE c, "Variable for month
v_count(2) TYPE c VALUE 0, "Variable for count
v_wdays(2) TYPE c VALUE 0, "Variable for working days
v_ndays(2) TYPE c VALUE 0, "Variable for non work days
v_tdays(2) TYPE c VALUE 0, "Variable for total days
v_oltot TYPE i VALUE 0, "Variable for order total
v_sotot TYPE i VALUE 0, "Variable for special order
v_corebus TYPE kzwi2 VALUE 0, "Variable for core bus
v_onbulk TYPE kzwi2 VALUE 0, "Variable for bulk orders
v_premier TYPE kzwi2 VALUE 0, "Variable for premier prog
v_shipit TYPE kzwi2 VALUE 0, "Variable for ship it prog
v_onpromo TYPE kzwi2 VALUE 0, "Variable for on promo
v_netrev TYPE kzwi2 VALUE 0, "Variable for net rev
v_storev TYPE kzwi2 VALUE 0, "Variable for store rev
v_connet TYPE kzwi2 VALUE 0, "Variable for consignment
v_sporder TYPE kzwi2 VALUE 0, "Variable for special order
v_stdvd TYPE kzwi2 VALUE 0, "Variable for dvd
v_totrev TYPE kzwi2 VALUE 0, "Variable for total rev
v_totbud TYPE kzwi2 VALUE 0, "Variable for total budget
v_ordsize TYPE kzwi2 VALUE 0. "Variable for order size
TYPES *
*--Structure for VBRP Table
TYPES : BEGIN OF t_vbrp,
vbeln TYPE vbeln, "Billing document
fkdat TYPE fkdat, "Billing date
fktyp TYPE fktyp, "Billing category
fkart TYPE fkart, "Billing type
vtweg TYPE vtweg, "Distribution channel
knumv TYPE knumv, "Number of doc condition
posnr TYPE posnr, "Billing item
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "Plant
vgbel TYPE xblnr, "Referance
vgbel1 TYPE vgbel, "Doc no reference document
kzwi2 TYPE kzwi2, "Subtotal 2
wavwr TYPE wavwr, "Cost in document currency
kunnr TYPE kunnr, "Customer
END OF t_vbrp,
*--Structure for MKPF Table
BEGIN OF t_mkpf,
fkdat TYPE fkdat, "Billing date
mblnr TYPE mblnr, "Number of material document
mjahr TYPE mjahr, "Material doc. year
xblnr TYPE xblnr, "Referance
kunnr TYPE kunnr, "Customer
END OF t_mkpf,
*--Structure for MSEG Table
BEGIN OF t_mseg,
fkdat TYPE fkdat, "Billing date
mblnr TYPE mblnr, "Number of material document
mjahr TYPE mjahr, "Material doc. year
bwart TYPE bwart, "Movement type
sobkz TYPE sobkz, "Special Stock indicator
dmbtr TYPE dmbtr, "Amount in local currency
kunnr TYPE kunnr, "Customer
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "Plant
END OF t_mseg,
*--Structure for LIPS Table
BEGIN OF t_lips,
vbeln TYPE vbeln_vl, "Delivery
fkdat TYPE fkdat, "Billing date
knumv TYPE knumv, "Number of doc condition
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "Plant
bwart TYPE bwart, "Movement type
kzwi2 TYPE kzwi2, "Subtotal 2
lfimg TYPE lfimg, "Quantity
END OF t_lips,
*--Structure for VBAK Table
BEGIN OF t_vbak,
erdat TYPE erdat, "Created On
vbeln TYPE vbeln_va, "Delivery
auart TYPE auart, "Sales document type
vtweg TYPE vtweg, "Distribution channel
knumv TYPE knumv, "Number of doc condition
END OF t_vbak,
*--Structure for KONV Table
BEGIN OF t_konv,
knumv TYPE knumv, "Number of doc condition
kschl TYPE kscha, "Condition type
kbetr TYPE kbetr, "Rate
END OF t_konv,
*--Structure for DUMMY Table
BEGIN OF t_dummy,
fkdat TYPE fkdat, "Billing date
matnr TYPE matnr, "Material Number
bwart TYPE bwart, "Movement type
kbetr TYPE kzwi2, "Net value of billing item
END OF t_dummy,
*--Structure for NDAY table
BEGIN OF t_nday,
erdat TYPE erdat, "Created On
flag(1) TYPE c, "Flag
END OF t_nday,
*--Structure for TFACS Table
BEGIN OF t_tfacs,
ident TYPE wfcid, "Factory calendar ID
jahr TYPE kjahr, "Fiscal Year
mon01 TYPE mon00, "Calendar: Days in a month
mon02 TYPE mon00, "Calendar: Days in a month
mon03 TYPE mon00, "Calendar: Days in a month
mon04 TYPE mon00, "Calendar: Days in a month
mon05 TYPE mon00, "Calendar: Days in a month
mon06 TYPE mon00, "Calendar: Days in a month
mon07 TYPE mon00, "Calendar: Days in a month
mon08 TYPE mon00, "Calendar: Days in a month
mon09 TYPE mon00, "Calendar: Days in a month
mon10 TYPE mon00, "Calendar: Days in a month
mon11 TYPE mon00, "Calendar: Days in a month
mon12 TYPE mon00, "Calendar: Days in a month
END OF t_tfacs,
*--Structure for shipping days table.
BEGIN OF t_ship,
title(35) TYPE c, "Title
days(10) TYPE c, "Days
END OF t_ship,
*--Structure for Final Table
BEGIN OF t_final,
erdat TYPE erdat, "Date
oltot TYPE i, "Online Order total
sotot TYPE i, "Special Order Total
corebus TYPE kzwi2, "ECS Online Promo Rev
onbulk TYPE kzwi2, "ECS online Bulk Orders
premier TYPE kzwi2, "MSFT Premier Program
shipit TYPE kzwi2, "MSFT online shipit program
onpromo TYPE kzwi2, "MSFT online promo rev
netrev TYPE kzwi2, "MSFT/Xbox Consignment
storev TYPE kzwi2, "MSFT Retail Store promo rev
connet TYPE kzwi2, "MSFT Retail Consign net rev
sporder TYPE kzwi2, "Special order revenue
stdvd TYPE kzwi2, "Traveling Store/DVD
totrev TYPE kzwi2, "Total ECS Revenue
totbud TYPE kzwi2, "Total ECS Budget
ordsize TYPE kzwi2, "Avg online order size
END OF t_final,
*--Structure for Total Table
BEGIN OF t_total,
title(10) TYPE c, "Date
oltot TYPE i, "Online Order total
sotot TYPE i, "Special Order Total
corebus TYPE kzwi2, "ECS Online Promo Rev
onbulk TYPE kzwi2, "ECS online Bulk Orders
premier TYPE kzwi2, "MSFT Premier Program
shipit TYPE kzwi2, "MSFT online shipit program
onpromo TYPE kzwi2, "MSFT online promo rev
netrev TYPE kzwi2, "MSFT/Xbox Consignment
storev TYPE kzwi2, "MSFT Retail Store promo rev
connet TYPE kzwi2, "MSFT Retail Consign net rev
sporder TYPE kzwi2, "Special order revenue
stdvd TYPE kzwi2, "Traveling Store/DVD
totrev TYPE kzwi2, "Total ECS Revenue
totbud TYPE kzwi2, "Total ECS Budget
ordsize TYPE kzwi2, "Avg online order size
END OF t_total,
*--Structure for MKPF Table
BEGIN OF t_jkmkpf,
budat TYPE budat, "Posting date
mblnr TYPE mblnr, "Number of material document
mjahr TYPE mjahr, "Material doc. year
END OF t_jkmkpf,
*--Structure for MSEG Table
BEGIN OF t_jkmseg,
fkdat TYPE fkdat, "Billing date
matnr TYPE matnr, "Material Number
mblnr TYPE mblnr, "Number of material document
mjahr TYPE mjahr, "Material doc. year
bwart TYPE bwart, "Movement type
menge TYPE menge_d, "Quantity
kbetr TYPE kbetr_kond, "Rate
dmbtr TYPE dmbtr, "Amount in local currency
END OF t_jkmseg,
*--Structure for A006 Table
BEGIN OF t_a006,
fkdat TYPE fkdat, "Billing date
matnr TYPE matnr, "Material Number
kappl TYPE kappl, "Application
kschl TYPE kschl, "Condition type
vkorg TYPE vkorg, "Sales organization
vtweg TYPE vtweg, "Distribution channel
datbi TYPE kodatbi, "Validity end date
datab TYPE kodatab, "Validity start date
knumh TYPE knumh, "Condition record number
END OF t_a006,
*--Structure for KONP Table
BEGIN OF t_konp,
fkdat TYPE fkdat, "Billing date
matnr TYPE matnr, "Material Number
knumh TYPE knumh, "Condition record number
kappl TYPE kappl, "Application
kschl TYPE kschl, "Condition type
kbetr TYPE kbetr_kond, "Rate
END OF t_konp.
WORK AREAS *
DATA : wa_vbrp TYPE t_vbrp, "Work area for VBRP Table
wa_mkpf TYPE t_mkpf, "Work area for MKPF Table
wa_mseg TYPE t_mseg, "Work area for MSEG Table
wa_jkmkpf TYPE t_jkmkpf, "Work area for MKPF Table
wa_jkmseg TYPE t_jkmseg, "Work area for MSEG Table
wa_kjmseg TYPE t_jkmseg, "Work area for MSEG Table
wa_lips TYPE t_lips, "Work area for LIPS Table
wa_vbak TYPE t_vbak, "Work area for VBAK Table
wa_konv TYPE t_konv, "Work area for KONV Table
wa_dummy TYPE t_dummy, "Work area for DUMMY Table
wa_tfacs TYPE t_tfacs, "Work area for TFACS Table
wa_final TYPE t_final, "Work area for Final Table
wa_total TYPE t_total, "Work area for Total Table
wa_ship TYPE t_ship, "Work area for Ship Table
wa_a006 TYPE t_a006,
wa_konp TYPE t_konp, "Work area for KONP Table
wa_nday TYPE t_nday,
wa_fieldcat TYPE slis_fieldcat_alv,"Work area for fieldcatalog
wa_layout1 TYPE slis_layout_alv,
wa_layout2 TYPE slis_layout_alv,
wa_layout3 TYPE slis_layout_alv.
INTERNAL TABLES *
DATA : it_vbrp TYPE STANDARD TABLE OF t_vbrp INITIAL SIZE 0,
it_mkpf TYPE STANDARD TABLE OF t_mkpf INITIAL SIZE 0,
it_mseg TYPE STANDARD TABLE OF t_mseg INITIAL SIZE 0,
it_jkmkpf TYPE STANDARD TABLE OF t_jkmkpf INITIAL SIZE 0,
it_jkmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
it_kjmseg TYPE STANDARD TABLE OF t_jkmseg INITIAL SIZE 0,
it_lips TYPE STANDARD TABLE OF t_lips INITIAL SIZE 0,
it_vbak TYPE STANDARD TABLE OF t_vbak INITIAL SIZE 0,
it_konv TYPE STANDARD TABLE OF t_konv INITIAL SIZE 0,
it_dummy TYPE STANDARD TABLE OF t_dummy INITIAL SIZE 0,
it_tfacs TYPE STANDARD TABLE OF t_tfacs INITIAL SIZE 0,
it_final TYPE STANDARD TABLE OF t_final INITIAL SIZE 0,
it_total TYPE STANDARD TABLE OF t_total INITIAL SIZE 0,
it_ship TYPE STANDARD TABLE OF t_ship INITIAL SIZE 0,
it_nday TYPE STANDARD TABLE OF t_nday INITIAL SIZE 0,
it_a006 TYPE STANDARD TABLE OF t_a006 INITIAL SIZE 0,
it_konp TYPE STANDARD TABLE OF t_konp INITIAL SIZE 0,
it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_fieldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_events TYPE slis_t_event,
it_event1 TYPE slis_t_event,
it_event2 TYPE slis_t_event,
it_header TYPE slis_t_listheader.
PARAMETERS & SELECT-OPTIONS *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_erdat FOR vbak-erdat NO-DISPLAY. "Created On
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(10) text-003.
PARAMETERS : p_month(7) TYPE c OBLIGATORY. "Month
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(40) text-030.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(10) text-004.
PARAMETERS : p_bud(16) TYPE c OBLIGATORY. "Budget
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK blk1.
AT SELECTION SCREEN *
AT SELECTION-SCREEN ON p_month.
*--Create the date range
PERFORM sub_create_date.
START-OF-SELECTION *
START-OF-SELECTION.
*--Select data from TFACS Table
PERFORM sub_read_tfacs.
*--Select Data from VBAK Table
PERFORM sub_read_vbak.
*--Select Data from VBRP Table
PERFORM sub_read_vbrp.
*--Select Data from MKPF Table
PERFORM sub_read_mkpf.
*--Select Data from MSEG Table
PERFORM sub_read_mseg.
*--Select Data from LIPS Table
PERFORM sub_read_lips.
*--Select Data from KONV Table
PERFORM sub_read_konv.
*--Collect all the data into final inetrnal table
PERFORM sub_collect_data.
*--Collect all the data into final inetrnal table
PERFORM sub_collect_vbrp.
*--Collect all the data into final inetrnal table
PERFORM sub_collect_lips.
*--Collect MSFT retail store promo rev & MSFT retail
store consignment net rev
PERFORM sub_jk_column.
*--Collect consignment cost
PERFORM sub_collect_consign.
*--Calculate Plug Numbers
PERFORM sub_claculate_plug.
*--Collect data from vbrp
PERFORM sub_collect_cost.
*--Calculate the total & avarages
PERFORM sub_calculate_total.
*--Collect totals & avarages into final internal table
PERFORM sub_collect_total.
END-OF-SELECTION *
END-OF-SELECTION.
*--This perform creates the ALV events
PERFORM sub_create_events.
*--This perform prepare field catalog.
PERFORM sub_field_catalogmerge.
*--This perform displays an ALV report
PERFORM sub_alv_display.
*& Form sub_read_vbrp
text
FORM sub_read_vbrp .
*--Local Variables
DATA : lv_index LIKE sy-tabix.
*--Select query to pick the Billing document Billing date Billing
category Billing type Distribution channel Number of doc condition
Billing item Material Number Plant Referance Subtotal 2 Cost in
document currency and Partner function from table VBRK VBRP and VBPA
using inner join
SELECT a~vbeln "Billing document
a~fkdat "Billing date
a~fktyp "Billing category
a~fkart "Billing type
a~vtweg "Distribution channel
a~knumv "Number of doc condition
b~posnr "Billing item
b~matnr "Material Number
b~werks "Plant
b~vgbel "Referance
b~kzwi2 "Subtotal 2
b~wavwr "Cost in document currency
c~kunnr "Partner function
FROM vbrk AS a
INNER JOIN vbrp AS b
ON avbeln EQ bvbeln
INNER JOIN vbpa AS c
ON bvbeln EQ cvbeln
INTO CORRESPONDING FIELDS OF TABLE it_vbrp
WHERE fkdat IN s_erdat
AND parvw EQ 'ZS'.
IF sy-subrc EQ 0.
*--Sort table by Referance
SORT it_vbrp BY vgbel1.
ENDIF.
LOOP AT it_vbrp INTO wa_vbrp.
lv_index = sy-tabix.
wa_vbrp-vgbel1 = wa_vbrp-vgbel.
MODIFY it_vbrp FROM wa_vbrp INDEX lv_index TRANSPORTING
vgbel1.
*--Clear
CLEAR : wa_vbrp.
ENDLOOP.
ENDFORM. " sub_read_vbrp
*& Form sub_read_mkpf
text
FORM sub_read_mkpf .
*--Local Variables
DATA : lv_index LIKE sy-tabix.
IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Number of material document Material
document year and Referance from table MKPF
SELECT DISTINCT
mblnr "Number of material document
mjahr "Material doc. year
xblnr "Referance
FROM mkpf
INTO CORRESPONDING FIELDS OF TABLE it_mkpf
FOR ALL ENTRIES IN it_vbrp
WHERE xblnr EQ it_vbrp-vgbel.
ENDIF.
*--Sort table by No of material document and fiscal year
SORT it_mkpf BY mblnr mjahr.
IF sy-subrc EQ 0.
DELETE ADJACENT DUPLICATES FROM it_mkpf COMPARING mblnr mjahr.
ENDIF.
*--Sort table by referance document
SORT it_vbrp BY vgbel.
SORT it_mkpf BY xblnr.
IF NOT it_mkpf[] IS INITIAL.
LOOP AT it_mkpf INTO wa_mkpf.
lv_index = sy-tabix.
*--Clear
CLEAR : wa_vbrp.
READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel = wa_mkpf-xblnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_mkpf-fkdat = wa_vbrp-fkdat.
wa_mkpf-kunnr = wa_vbrp-kunnr.
ENDIF.
MODIFY it_mkpf FROM wa_mkpf INDEX lv_index TRANSPORTING
fkdat kunnr.
*--Clear
CLEAR : wa_mkpf.
ENDLOOP.
ENDIF.
ENDFORM. " sub_read_mkpf
*& Form sub_read_mseg
text
FORM sub_read_mseg .
*--Local Variables
DATA : lv_index LIKE sy-tabix.
IF NOT it_mkpf[] IS INITIAL.
*--Select query to pick the Number of material document Material
document year Movement type Special Stock indicator and Amount in
local currency from table MSEG
SELECT mblnr "Number of material document
mjahr "Material doc. year
bwart "Movement type
sobkz "Special Stock indicator
dmbtr "Amount in local currency
matnr "Material
werks "Plant
FROM mseg
INTO CORRESPONDING FIELDS OF TABLE it_mseg
FOR ALL ENTRIES IN it_mkpf
WHERE mblnr EQ it_mkpf-mblnr
AND mjahr EQ it_mkpf-mjahr.
AND bwart EQ '601'.
AND sobkz EQ 'K'.
ENDIF.
*--Sort table by Number of material document
SORT it_mkpf BY mblnr.
*--Sort table by Number of material document
SORT it_mseg BY mblnr.
IF NOT it_mseg[] IS INITIAL.
LOOP AT it_mseg INTO wa_mseg.
lv_index = sy-tabix.
*--Clear
CLEAR : wa_mkpf.
READ TABLE it_mkpf INTO wa_mkpf WITH KEY mblnr = wa_mseg-mblnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_mseg-fkdat = wa_mkpf-fkdat.
wa_mseg-kunnr = wa_mkpf-kunnr.
ENDIF.
MODIFY it_mseg FROM wa_mseg INDEX lv_index TRANSPORTING
fkdat kunnr.
*--Clear
CLEAR: wa_mseg.
ENDLOOP.
ENDIF.
ENDFORM. " sub_read_mseg
*& Form sub_read_lips
text
FORM sub_read_lips .
*--Local Variables
DATA : lv_index LIKE sy-tabix.
IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Delivery Material Number Plant
Movement type Subtotal 2 and Quantity from table LIPS
SELECT vbeln "Delivery
matnr "Material Number
werks "Plant
bwart "Movement type
kzwi2 "Subtotal 2
lfimg "Quantity
FROM lips
INTO CORRESPONDING FIELDS OF TABLE it_lips
FOR ALL ENTRIES IN it_vbrp
WHERE vbeln EQ it_vbrp-vgbel1.
IF sy-subrc EQ 0.
*--Sort table by Delivery
SORT it_lips BY vbeln.
ENDIF.
ENDIF.
*--Sort table
SORT it_vbrp BY vgbel1.
LOOP AT it_lips INTO wa_lips.
lv_index = sy-tabix.
*--CLear
CLEAR : wa_vbrp.
READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel1 = wa_lips-vbeln
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_lips-fkdat = wa_vbrp-fkdat.
wa_lips-knumv = wa_vbrp-knumv.
ENDIF.
MODIFY it_lips FROM wa_lips INDEX lv_index TRANSPORTING
fkdat knumv.
*--Clear
CLEAR : wa_lips.
ENDLOOP.
ENDFORM. " sub_read_lips
*& Form sub_read_konv
text
FORM sub_read_konv .
IF NOT it_vbrp[] IS INITIAL.
*--Select query to pick the Number of doc condition Condition type
and Rate from table KONV
SELECT knumv "Number of doc condition
kschl "Condition type
kbetr "Rate
FROM konv
INTO TABLE it_konv
FOR ALL ENTRIES IN it_vbrp
WHERE knumv EQ it_vbrp-knumv
AND kschl EQ 'ZR00'.
ENDIF.
ENDFORM. " sub_read_konv
*& Form sub_read_vbak
text
FORM sub_read_vbak .
*--Select query to pick the Created On Delivery Sales document type
Distribution channel and Number of doc condition from table VBAK
SELECT erdat "Created On
vbeln "Delivery
auart "Sales document type
vtweg "Distribution channel
knumv "Number of doc condition
FROM vbak
INTO TABLE it_vbak
WHERE erdat IN s_erdat.
IF sy-subrc EQ 0.
*--Sort table by created on
SORT it_vbak BY erdat.
ENDIF.
ENDFORM. " sub_read_vbak
Regards,
prashant -
Hi.....
how we maintain list headings in case of alv interactive reporting.
please provide some logic hints if possible.Hi
See the sample report..Reward points for the same as per SDN rules and regulations
report ZRGRIRNA no standard page heading
line-count 65
line-size 255
message-id mm.
GR IR Detail Report *
Description : The output has to be displayed
in the ALV Grid format with the Selection *
screen appearing on the output. In The Output *
Subtotals for Vendor, Plant, Period, Material,*
Valuation Class, Purchase Order,Cost Center, *
Cost Element and Receipt Date are displayed *
after sorting the data by same fields. *
Declaration for Tables
tables: t001, " Company Codes
t001w, " Plants/Branches
lfa1, " Vendor Master
ska1, " GL Account Master
mara, " Material Master
mbew, " Material Valuation
ekko, " PO Header Data
cska, " Cost Elements
csks, " Cost Centers
bsis, " GL Accounts: Open Items Data
bkpf. " Accounting Doc: Header Data
Type-pools
Type pools for ALV display
type-pools : slis.
Global variables
data: g_repid like sy-repid,
g_exit type c,
g_events type slis_t_event,
g_list_top_of_page type slis_t_listheader,
g_exit_caused_by_caller,
g_exit_caused_by_user type slis_exit_by_user,
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_variant like disvariant,
g_save.
Declaration for Constants
constants : c_x type c value 'X', " Flag
c_c type c value 'C', " Flag
c_l type c value 'L', " Flag
c_a type c value 'A', " Line Type
c_h type c value 'H', " Dr/Cr
c_s type c value 'S', " Line Type
c_mkpf(4) type c value 'MKPF'. " Table
Declaration of Internal Tables
Internal Table for BSIS Table data
data: begin of i_bsis occurs 0,
bukrs like bsis-bukrs, " Company Code
hkont like bsis-hkont, " GR IR Account
gjahr like bsis-gjahr, " Fiscal Year
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
budat like bsis-budat, " Receipt Date(Posting)
monat like bsis-monat, " Period
end of i_bsis.
Internal Table for BSEG Table data
data: begin of i_bseg occurs 0,
bukrs like bsis-bukrs, " Company Code
belnr like bsis-belnr, " Acc Document
buzei like bsis-buzei, " Item No
gjahr like bsis-gjahr, " Fiscal Year
shkzg like bseg-shkzg, " Dr/Cr Indicator
lifnr like bseg-lifnr, " Vendor Code
matnr like bseg-matnr, " Material No
ebeln like bseg-ebeln, " Purchase Order
ebelp like bseg-ebelp, " PO Item
werks like bseg-werks, " Plant
menge like bseg-menge, " PO Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Amount in Local Currency
wrbtr like bseg-wrbtr, " Amount in Trans.Currency
end of i_bseg.
Internal Table for BKPF Table data
data: begin of i_bkpf occurs 0,
bukrs like bkpf-bukrs, " Company Code
belnr like bkpf-belnr, " Acc Document
gjahr like bkpf-gjahr, " Fiscal Year
waers like bkpf-waers, " Trans. Currency
awkey like bkpf-awkey, " Object Key
awtyp like bkpf-awtyp, " Reference Procedure
end of i_bkpf.
Internal Table for MSEG Table data
data: begin of i_mseg occurs 0,
mblnr like mseg-mblnr, " Material Document
mjahr like mseg-mjahr, " Fiscal Year
bwart like mseg-bwart, " Movement Type
matnr like mseg-matnr, " Material No
menge like mseg-menge, " PO Quantity
meins like mseg-meins, " UOM
end of i_mseg.
Internal Table for MBEW Table data
data: begin of i_mbew occurs 0,
matnr like mbew-matnr, " Material No
werks like mbew-bwkey, " Plant
bklas like mbew-bklas, " Valuation Class
end of i_mbew.
Internal Table for EKPO Table data
data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln, " Purchase Order
ebelp like ekpo-ebelp, " PO Item
matnr like ekpo-matnr, " Material No
txz01 like ekpo-txz01, " Material Text
end of i_ekpo.
Internal Table for EKKN Table data
data: begin of i_ekkn occurs 0,
ebeln like ekkn-ebeln, " Purchase Order
ebelp like ekkn-ebelp, " PO Item
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
end of i_ekkn.
Internal Table for LFA1 Table data
data: begin of i_lfa1 occurs 0,
lifnr like lfa1-lifnr, " Vendor
name1 like lfa1-name1, " Name
end of i_lfa1.
Declaration of Output Internal Table
data: begin of i_final occurs 0,
lifnr like lfa1-lifnr, " Vendor
werks like bseg-werks, " Plant
monat like bsis-monat, " Period
matnr like mara-matnr, " Material Number
bklas like mbew-bklas, " Val Class
ebeln like bseg-ebeln, " PO
kostl like ekkn-kostl, " Cost Center
sakto like ekkn-sakto, " Cost Element
budat like bsis-budat, " Rec. Date
name1 like lfa1-name1, " Vendor Name
belnr like bsis-belnr, " FI Document
bwart like mseg-bwart, " Movement Type
txz01 like ekpo-txz01, " Material Text
menge like bseg-menge, " Quantity
meins like bseg-meins, " UOM
dmbtr like bseg-dmbtr, " Local Amount
wrbtr like bseg-wrbtr, " Tran.Amount
waers like bkpf-waers, " Tran.Currency
status type c, " Material Status
end of i_final.
Internal table to hold field catgory data
data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals
Structure
data: x_layout type slis_layout_alv, " Structure-layout
x_fldcat like line of i_fldcat, " Structure-field catagory
x_sort like line of i_sort. " Structure-Sort/Subtotals
Selection screen
selection-screen : begin of block b1 with frame title text-000.
parameters:
p_bukrs like t001-bukrs obligatory, " Company Code
p_grira like ska1-saknr default '0241101000' obligatory. " Account
select-options:
s_budat for bkpf-budat, " Posting Date
s_werks for t001w-werks, " Plant
s_lifnr for lfa1-lifnr, " Vendor
s_matnr for mara-matnr, " Material Number
s_kostl for csks-kostl, " Cost Center
s_kstar for cska-kstar, " Cost Element
s_ebeln for ekko-ebeln, " Purchase Order
s_monat for bsis-monat. " Period
selection-screen skip.
parameters:
p_incmt as checkbox default 'X',
p_incnm as checkbox default 'X'.
selection-screen end of block b1.
Initialization
initialization.
g_repid = sy-repid.
perform layout_init using x_layout.
perform eventtab_build using g_events[].
g_variant-report = g_repid.
g_save = 'A'.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
perform validate_screen.
Start of selection
start-of-selection.
Read Data from Database Tables
perform read_data.
End of selection
end-of-selection.
Build layout report layout.
perform populate_layout_stucture.
Perform build_field_catalog and Sort Table
perform build_field_catalog.
perform build_sort_totals.
List Header for Top-Of-Page
perform comment_build using g_list_top_of_page[].
Call list viewer function module
perform call_list_viewer .
****************Form - Routines**************************************
Form : layout_init
Description : Form to Build layout for list display
form layout_init using rs_layout type slis_layout_alv.
rs_layout-detail_popup = c_x.
endform.
Form : Eventtab_build
Description : Registration of events to happen during list display
form eventtab_build using rt_events type slis_t_event.
Registration of events to happen during list display
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = rt_events.
read table rt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move g_top_of_page to ls_event-form.
append ls_event to rt_events.
endif.
endform. "eventtab_build
Form : top_of_page
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
I_LOGO = 'ENJOYSAP_LOGO'
it_list_commentary = g_list_top_of_page.
endform.
Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Company Code
clear t001.
if not p_bukrs is initial.
select single bukrs
into t001-bukrs
from t001
where bukrs eq p_bukrs.
if sy-subrc <> 0.
message e899 with 'Enter Valid Company Code'(012).
endif.
endif.
Validation of GL Account (GR/IR)
clear ska1.
if not p_grira is initial.
select saknr
into ska1-saknr
from ska1
up to 1 rows
where saknr eq p_grira.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid GR/IR Account'(013).
endif.
endif.
Validation of Vendor Code
clear lfa1.
if not s_lifnr[] is initial.
select single lifnr
into lfa1-lifnr
from lfa1
where lifnr in s_lifnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Vendor'(001).
endif.
endif.
Validation of Plant Code
clear t001w.
if not s_werks[] is initial.
select single werks
into t001w-werks
from t001w
where werks in s_werks.
if sy-subrc <> 0.
message e899 with 'Enter Valid Plant'(014).
endif.
endif.
Validation of Material Code
clear mara.
if not s_matnr[] is initial.
select single matnr
into mara-matnr
from mara
where matnr in s_matnr.
if sy-subrc <> 0.
message e899 with 'Enter Valid Material'(015).
endif.
endif.
Validation of Purchase Order
clear ekko.
if not s_ebeln[] is initial.
select single ebeln
into ekko-ebeln
from ekko
where ebeln in s_ebeln.
if sy-subrc <> 0.
message e899 with 'Enter Valid Purchase Order'(016).
endif.
endif.
Validation of Cost Center
clear csks.
if not s_kostl[] is initial.
select kostl
into csks-kostl
from csks
up to 1 rows
where kostl in s_kostl.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Center'(017).
endif.
endif.
Validation of Cost Element
clear cska.
if not s_kstar[] is initial.
select kstar
into cska-kstar
from cska
up to 1 rows
where kstar in s_kstar.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Cost Element'(018).
endif.
endif.
endform. "validate_screen
*& Form read_data
Read the Data from the database Tables
form read_data.
Get the Accounting Documents for the GR/IR Account Entered on
Selection Screen
clear i_bsis.
refresh i_bsis.
select bukrs " Company Code
hkont " GR IR Account
gjahr " Fiscal Year
belnr " Acc Document
buzei " Item No
budat " Receipt Date(Posting)
monat " Period
into table i_bsis
from bsis
where bukrs = p_bukrs
and hkont = p_grira
and budat in s_budat
and monat in s_monat .
if sy-subrc <> 0.
message i899 with 'No data found'(043).
g_exit = c_x.
stop.
endif.
sort i_bsis by bukrs hkont gjahr belnr buzei.
Get the Vendor,PO,Material,Qty details from BSEG Table
if not i_bsis[] is initial.
clear i_bseg.
refresh i_bseg.
select bukrs " Company Code
belnr " Acc Document
buzei " Item No
gjahr " Fiscal Year
shkzg " Dr/Cr Indicator
lifnr " Vendor Code
matnr " Material No
ebeln " Purchase Order
ebelp " PO Item
werks " Plant
menge " PO Quantity
meins " UOM
dmbtr " Amount in Local Currency
wrbtr " Amount in Trans.Currency
into table i_bseg
from bseg
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr
and buzei = i_bsis-buzei
and lifnr in s_lifnr
and werks in s_werks
and matnr in s_matnr
and ebeln in s_ebeln.
sort i_bseg by bukrs belnr buzei gjahr.
Select the Trans.Currency from BKPF Table
clear i_bkpf.
refresh i_bkpf.
select bukrs " Company Code
belnr " Acc Document
gjahr " Fiscal Year
waers " Trans. Currency
awkey " Object Key
awtyp " Reference Procedure
into table i_bkpf
from bkpf
for all entries in i_bsis
where bukrs = p_bukrs
and belnr = i_bsis-belnr
and gjahr = i_bsis-gjahr.
endif.
sort i_bkpf by bukrs belnr gjahr.
Get the Quantity and UOM of Material from MSEG Table
if not i_bkpf[] is initial.
clear i_mseg.
refresh i_mseg.
select mblnr " Material Document
mjahr " Fiscal Year
bwart " Movement Type
matnr " Material No
menge " PO Quantity
meins " UOM
into table i_mseg
from mseg
for all entries in i_bkpf
where mblnr = i_bkpf-awkey(10).
endif.
sort i_mseg by mblnr mjahr.
Get the Material And Description from EKPO Table
if not i_bseg[] is initial.
clear i_ekpo.
refresh i_ekpo.
select ebeln " Purchase Order
ebelp " PO Item
matnr " Material No
txz01 " Material Text
into table i_ekpo
from ekpo
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp.
sort i_ekpo by ebeln ebelp.
Get the Valuation Class from MBEW Table
clear i_mbew.
refresh i_mbew.
select matnr " Material No
bwkey " Plant
bklas " Valuation Class
into table i_mbew
from mbew
for all entries in i_bseg
where matnr = i_bseg-matnr
and bwkey = i_bseg-werks.
sort i_mbew by matnr werks.
Get the Cost Center and Cost Element of the PO from EKKN Table
clear i_ekkn.
refresh i_ekkn.
select ebeln " Purchase Order
ebelp " PO Item
kostl " Cost Center
sakto " Cost Element
into table i_ekkn
from ekkn
for all entries in i_bseg
where ebeln = i_bseg-ebeln
and ebelp = i_bseg-ebelp
and kostl in s_kostl
and sakto in s_kstar.
sort i_ekkn by ebeln ebelp.
Get the Vendor Name
clear i_lfa1.
refresh i_lfa1.
select lifnr " Vendor
name1 " Name
into table i_lfa1
from lfa1
for all entries in i_bseg
where lifnr = i_bseg-lifnr.
endif.
sort i_lfa1 by lifnr.
Move the data to Final Output Internal Table
loop at i_bsis.
i_final-belnr = i_bsis-belnr. " FI Document
i_final-monat = i_bsis-monat. " Period
i_final-budat = i_bsis-budat. " Rec. Date
Read the Transaction Currency from BKPF Internal Table
read table i_bkpf with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
binary search.
if sy-subrc = 0.
i_final-waers = i_bkpf-waers. " Tran.Currency
Read the Movement Type for all Material Related
Documents from MSEG Internal Table
if i_bkpf-awtyp = c_mkpf.
read table i_mseg with key mblnr = i_bkpf-awkey(10)
mjahr = i_bkpf-awkey+10(4).
if sy-subrc = 0.
i_final-bwart = i_mseg-bwart. " Movement Type
endif.
endif.
endif.
Read Vendor, Plant, PO Document, Local And Trans.Amounts
from BSEG Internal Table
read table i_bseg with key bukrs = i_bsis-bukrs
belnr = i_bsis-belnr
gjahr = i_bsis-gjahr
buzei = i_bsis-buzei
binary search.
if sy-subrc = 0.
i_final-lifnr = i_bseg-lifnr. " Vendor
i_final-werks = i_bseg-werks. " Plant
i_final-ebeln = i_bseg-ebeln. " PO
i_final-dmbtr = i_bseg-dmbtr. " Local Amount
i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount
i_final-menge = i_bseg-menge. " Quantity
i_final-meins = i_bseg-meins. " UOM
For Credit Indicator(SHKZG = H) amounts should be (-)ve
if i_bseg-shkzg = c_h.
i_final-dmbtr = i_final-dmbtr * -1.
i_final-wrbtr = i_final-wrbtr * -1.
i_final-menge = i_final-menge * -1.
endif.
Read the Material and its Description from EKPO Internal Table
read table i_ekpo with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
matnr = i_bseg-matnr
binary search.
if sy-subrc = 0.
i_final-matnr = i_ekpo-matnr. " Material Number
i_final-txz01 = i_ekpo-txz01. " Material Text
Populate the Material Status depending on the Input Checkbox
On Selection Screen
if not i_ekpo-matnr is initial.
i_final-status = c_x.
endif.
endif.
Read the PO related Cost Element and Cost Centers
from EKKN Internal Table
read table i_ekkn with key ebeln = i_bseg-ebeln
ebelp = i_bseg-ebelp
binary search.
if sy-subrc = 0.
i_final-kostl = i_ekkn-kostl. " Cost Center
i_final-sakto = i_ekkn-sakto. " Cost Element
endif.
Read the Valuation Class from MBEW Internal Table
read table i_mbew with key matnr = i_bseg-matnr
werks = i_bseg-werks
binary search.
if sy-subrc = 0.
i_final-bklas = i_mbew-bklas. " Val Class
endif.
Read the Vendor Name from LFA1 Internal Table
read table i_lfa1 with key lifnr = i_bseg-lifnr
binary search.
if sy-subrc = 0.
i_final-name1 = i_lfa1-name1. " Vendor Name
endif.
endif.
append i_final.
clear i_final.
endloop.
sort i_final by lifnr werks monat matnr.
Depending on the check Box Selected display the data
if p_incmt = c_x and p_incnm ne c_x.
delete i_final where matnr eq space.
elseif p_incnm = c_x and p_incmt ne c_x.
delete i_final where matnr ne space.
endif.
endform. "Read Data
Form : populate_layout_stucture
Description : Populating the layout structure
form populate_layout_stucture.
clear x_layout .
Layout properties
x_layout-zebra = c_x.
x_layout-detail_popup = c_x.
x_layout-detail_initial_lines = c_x.
x_layout-colwidth_optimize = c_x.
endform. " populate_layout_stucture
Form : build_field_catalog
Description : Building the field catalog data
form build_field_catalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = g_repid
i_internal_tabname = 'I_FINAL'
i_inclname = g_repid
changing
ct_fieldcat = i_fldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Getting the Header text for the coloums
loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
fieldname = 'NAME1' or
fieldname = 'WERKS' or
fieldname = 'MONAT' or
fieldname = 'MATNR' or
fieldname = 'BKLAS' or
fieldname = 'EBELN' or
fieldname = 'KOSTL' or
fieldname = 'SAKTO' or
fieldname = 'BUDAT' or
fieldname = 'BELNR' or
fieldname = 'BWART' or
fieldname = 'TXZ01' or
fieldname = 'MENGE' or
fieldname = 'MEINS' or
fieldname = 'DMBTR' or
fieldname = 'WRBTR' or
fieldname = 'WAERS' or
fieldname = 'STATUS'.
if x_fldcat-fieldname = 'LIFNR'.
x_fldcat-seltext_l = 'Vendor'(003).
x_fldcat-seltext_m = 'Vendor'(003).
x_fldcat-seltext_s = 'Vendor'(003).
x_fldcat-reptext_ddic = 'Vendor'(003).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'NAME1'.
x_fldcat-seltext_l = 'Vendor Name'(002).
x_fldcat-seltext_m = 'Vendor Name'(002).
x_fldcat-seltext_s = 'Vendor Name'(002).
x_fldcat-reptext_ddic = 'Vendor Name'(002).
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'WERKS'.
x_fldcat-seltext_l = 'Plant'(010).
x_fldcat-seltext_m = 'Plant'(010).
x_fldcat-seltext_s = 'Plant'(010).
x_fldcat-reptext_ddic = 'Plant'(010).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MONAT'.
x_fldcat-seltext_l = 'Period'(011).
x_fldcat-seltext_m = 'Period'(011).
x_fldcat-seltext_s = 'Period'(011).
x_fldcat-reptext_ddic = 'Period'(011).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MATNR'.
x_fldcat-seltext_l = 'Material'(004).
x_fldcat-seltext_m = 'Material'(004).
x_fldcat-seltext_s = 'Material'(004).
x_fldcat-reptext_ddic = 'Material'(004).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BKLAS'.
x_fldcat-seltext_l = 'Valuation Class'(009).
x_fldcat-seltext_m = 'Valuation Class'(009).
x_fldcat-seltext_s = 'Valuation Class'(009).
x_fldcat-reptext_ddic = 'Valuation Class'(009).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'EBELN'.
x_fldcat-seltext_l = 'Purchase Order'(005).
x_fldcat-seltext_m = 'Purchase Order'(005).
x_fldcat-seltext_s = 'Purchase Order'(005).
x_fldcat-reptext_ddic = 'Purchase Order'(005).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'KOSTL'.
x_fldcat-seltext_l = 'Cost Center'(006).
x_fldcat-seltext_m = 'Cost Center'(006).
x_fldcat-seltext_s = 'Cost Center'(006).
x_fldcat-reptext_ddic = 'Cost Center'(006).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'SAKTO'.
x_fldcat-seltext_l = 'Cost Element'(007).
x_fldcat-seltext_m = 'Cost Element'(007).
x_fldcat-seltext_s = 'Cost Element'(007).
x_fldcat-reptext_ddic = 'Cost Element'(007).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BUDAT'.
x_fldcat-seltext_l = 'Receipt Date'(008).
x_fldcat-seltext_m = 'Receipt Date'(008).
x_fldcat-seltext_s = 'Receipt Date'(008).
x_fldcat-reptext_ddic = 'Receipt Date'(008).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BELNR'.
x_fldcat-seltext_l = 'Acc.Document'(100).
x_fldcat-seltext_m = 'Acc.Document'(100).
x_fldcat-seltext_s = 'Acc.Document'(100).
x_fldcat-reptext_ddic = 'Acc.Document'(100).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'BWART'.
x_fldcat-seltext_l = 'Movement Type'(101).
x_fldcat-seltext_m = 'Movement Type'(101).
x_fldcat-seltext_s = 'Movement Type'(101).
x_fldcat-reptext_ddic = 'Movement Type'(101).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'TXZ01'.
x_fldcat-seltext_l = 'Material Text'(102).
x_fldcat-seltext_m = 'Material Text'(102).
x_fldcat-seltext_s = 'Material Text'(102).
x_fldcat-reptext_ddic = 'Material Text'(102).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE'.
x_fldcat-seltext_l = 'Quantity'(103).
x_fldcat-seltext_m = 'Quantity'(103).
x_fldcat-seltext_s = 'Quantity'(103).
x_fldcat-reptext_ddic = 'Quantity'(103).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'(104).
x_fldcat-seltext_m = 'UOM'(104).
x_fldcat-seltext_s = 'UOM'(104).
x_fldcat-reptext_ddic = 'UOM'(104).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'DMBTR'.
x_fldcat-seltext_l = 'Amount in Local Curr'(105).
x_fldcat-seltext_m = 'Amount in Local Curr'(105).
x_fldcat-seltext_s = 'Amount in Local Curr'(105).
x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WRBTR'.
x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).
x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).
x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).
x_fldcat-ddictxt = c_l.
x_fldcat-do_sum = c_x.
endif.
if x_fldcat-fieldname = 'WAERS'.
x_fldcat-seltext_l = 'Trans.Currency'(107).
x_fldcat-seltext_m = 'Trans.Currency'(107).
x_fldcat-seltext_s = 'Trans.Currency'(107).
x_fldcat-reptext_ddic = 'Trans.Currency'(107).
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'STATUS'.
x_fldcat-seltext_l = 'Material Status'(019).
x_fldcat-seltext_m = 'Material Status'(019).
x_fldcat-seltext_s = 'Material Status'(019).
x_fldcat-reptext_ddic = 'Material Status'(019).
x_fldcat-ddictxt = c_l.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
endloop.
endform. " build_field_catalog
Form : build_sort_totals
Description : Building the Criteria for Sort/Subtotals
form build_sort_totals.
x_sort-fieldname = 'LIFNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'WERKS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MONAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 3.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MATNR'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 4.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BKLAS'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 5.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'EBELN'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 6.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'KOSTL'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 7.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'SAKTO'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 8.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'BUDAT'.
x_sort-tabname = 'I_FINAL'.
x_sort-spos = 9.
x_sort-up = c_x.
x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
endform. " build_sort_totals
Form : comment_build
Description : This form is used to display the Report Header(ALV)
form comment_build using lt_top_of_page type
slis_t_listheader.
data: l_line type slis_listheader,
l_heading1 like rs38m-repti,
l_date(10), l_time(8).
clear l_line.
l_heading1 = 'GR/IR DETAIL REPORT'(021).
g_repid = sy-repid.
write sy-uzeit to l_time.
write sy-datum to l_date.
l_line-typ = c_h.
move l_heading1 to l_line-info.
append l_line to lt_top_of_page.
clear l_line.
l_line-typ = c_s.
concatenate 'System:'(023) sy-sysid
'Date:'(024) l_date
' Time:'(025)
l_time into l_line-info.
append l_line to lt_top_of_page.
concatenate 'Report:'(026) g_repid
' User:'(027) sy-uname into
l_line-info.
append l_line to lt_top_of_page.
l_line-typ = c_a.
move 'SELECTION CRITERIA:'(028) to l_line-info.
append l_line to lt_top_of_page.
concatenate ' Company Code : '(029)
p_bukrs into l_line-info.
append l_line to lt_top_of_page.
concatenate ' GR/IR Account: '(030)
p_grira into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Posting Date : '(032) s_budat-low
' To: '(031) s_budat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Plant : '(033) s_werks-low
' To: '(031) s_werks-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Vendor: '(034) s_lifnr-low
' To: '(031) s_lifnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Material: '(035) s_matnr-low
' To: '(031) s_matnr-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Center : '(036) s_kostl-low
' To: '(031) s_kostl-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Cost Element: '(037) s_kstar-low
' To: '(031) s_kstar-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Purchase Order: '(038) s_ebeln-low
' To: '(031) s_ebeln-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Period : '(039) s_monat-low
' To: '(031) s_monat-high into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Material Items: '(040)
p_incmt into l_line-info.
append l_line to lt_top_of_page.
concatenate ' Include Non-Material Items: '(041)
p_incnm into l_line-info.
append l_line to lt_top_of_page.
endform.
Form : call_list_viewer
Description : This form is used to display the grid through ALV
form call_list_viewer.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = x_layout
it_fieldcat = i_fldcat[]
i_default = c_x
it_sort = i_sort[]
i_save = g_save
is_variant = g_variant
it_events = g_events[]
importing
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = g_exit_caused_by_user
tables
t_outtab = i_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
write: / 'Problem in calling the ALV report'(042).
endif.
endform. " call_list_viewer
<b>Reward points for useful Answers</b>
Regards
Anji
Maybe you are looking for
-
UCCE 7.5 Silent Monitoring for only primary supervisor
Hi all, We currently activate Silent Monitoring for our UCCE platform 7.5 using BIB and CCM based deployment. I'd like to enable the feature for only the team primary supervisor. Meaning the same supervisor, if configured as secondary for a different
-
I have a new iPad and I'd like to upload my Microsoft Office from my MAC desktop so I can sync them. Is that possible?
-
i have to create two pushbutton SELECTION-SCREEN PUSHBUTTON 10(20) TEXT-001 USER-COMMAND VIEW. SELECTION-SCREEN PUSHBUTTON 50(20) TEXT-002 USER-COMMAND EXIT. while at that time of click view i want to display all the records of internal table else
-
Tables with Spatial Columns sizing issues
Oracle EE latest everything So I have a table of link data as in: describe links ; Name Null? Type ID NUMBER NETWORK_ID NUMBER BEG_NODE_ID
-
If no ADO templates can be installed, what is next alternative?
Hi All, I have windows 8.1. I tried to install VS 2012 ultimate, VS 2013 ultimate, VS 2012 community - none of them provided ADO templates. I ran installer under "Run as Administrator" during all attempts. (1) I updated windows - except optional upda