Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3022

Document Series Block Control

$
0
0

Dear Experts,

 

 

Good Morning!!

 

 

I'm trying to control document based on document series wise.

 

 

Example :

 

 

Purchase Request Series : PR1, PR2,PR3, PR4, PR5, PR6, PR7, PR8, PR9, PR10, CC11

 

 

Purchase Order Series : PO1,PO2,PO3,PO4,PO5,PO6,PO7,PO8,PO9,PO10,CC11

 

GRPO SERIES : GRN1,GRN2,GRN3,GRN4,GRN5,GRN6,GRN7,GRN8,GRN9,GRN10,CC11,

 

 

 

Scenario :

 

User raise PR document from PR1 Series(Base Document) & then Target document PO trying to As "PO1"  not allow to add rest of series.

 

Please help me.

 

IF @object_type = '540000006' AND @transaction_type  in ( 'A' ,'U') -- Purchase Quotation

BEGIN

 

select @Basetype = t0.BaseType  from PQT1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from PQT1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = t0.Series   from OPQT t0 where @list_of_cols_val_tab_del = t0.DocEntry

 

 

if @Basetype = 'Purchase Request'

begin

   if not exists (select t0.docentry  from OPRQ t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

END

 

 

IF @object_type = '22' AND @transaction_type  in ( 'A' ,'U') -- Purchase Order

BEGIN

 

select @Basetype = t0.BaseType  from POR1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from POR1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = case when len(t1.SeriesName) = 8 then right(left(t1.SeriesName,4),2) else  right(left(t1.SeriesName,3),1) end    from OPOR  t0 join NNM1 t1 on t0.Series = t1.Series  where @list_of_cols_val_tab_del = t0.DocEntry

--SET @error = -147002

-- SET @error_message = @Basetype + ' ' + @BaseKey + ' ' + @TargetSeries

 

 

 

 

--if @Basetype = '1470000113'

-- begin

--  select @BaseSeries =  case when len(t1.SeriesName) = 8 then right(left(t1.SeriesName,4),2) else  right(left(t1.SeriesName,3),1) end    from OPRQ  t0 join NNM1 t1 on t0.Series = t1.Series  where @list_of_cols_val_tab_del = t0.DocEntry

 

--   if (@BaseSeries <> @TargetSeries)

--    begin

-- SET @error = -147002

--     SET @error_message = 'Please select the appropriate numbering series from the base document'

-- end

-- end

 

 

if @Basetype = 'Purchase Quotation'

begin

   if not exists (select t0.docentry  from OPQT t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

END

 

 

IF @object_type = '20' AND @transaction_type  in ( 'A' ,'U') -- GRPO

BEGIN

 

select @Basetype = t0.BaseType  from PDN1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from PDN1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = t0.Series   from OPDN  t0 where @list_of_cols_val_tab_del = t0.DocEntry

 

 

if @Basetype = 'Purchase Quotation'

begin

   if not exists (select t0.docentry  from OPQT t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

 

if @Basetype = 'Purchase Orders'

begin

   if not exists (select t0.docentry  from OPOR t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

END

 

 

IF @object_type = '21' AND @transaction_type  in ( 'A' ,'U') -- Goods Return

BEGIN

 

select @Basetype = t0.BaseType  from RPD1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from RPD1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = t0.Series   from ORPD  t0 where @list_of_cols_val_tab_del = t0.DocEntry

 

 

if @Basetype = 'Purchase Delivery Notes'

begin

   if not exists (select t0.docentry  from OPDN t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

  

END

 

 

IF @object_type = '18' AND @transaction_type  in ( 'A' ,'U') -- A/P Invoice

BEGIN

 

select @Basetype = t0.BaseType  from PCH1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from PCH1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = t0.Series   from OPCH  t0 where @list_of_cols_val_tab_del = t0.DocEntry

 

 

if @Basetype = 'Purchase Quotation'

begin

   if not exists (select t0.docentry  from OPQT t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

 

if @Basetype = 'Purchase Orders'

begin

   if not exists (select t0.docentry  from OPOR t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

 

 

if @Basetype = 'Purchase Delivery Notes'

begin

   if not exists (select t0.docentry  from OPDN t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

  

END

 

 

IF @object_type = '19' AND @transaction_type  in ( 'A' ,'U') -- A/P credit note

BEGIN

 

select @Basetype = t0.BaseType  from RPC1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @BaseKey = t0.BaseEntry   from RPC1 t0 where @list_of_cols_val_tab_del = t0.DocEntry

select @TargetSeries = t0.Series   from ORPC  t0 where @list_of_cols_val_tab_del = t0.DocEntry

 

 

if @Basetype = 'A/P Invoice'

begin

   if not exists (select t0.docentry  from OPCH t0 where @list_of_cols_val_tab_del = t0.DocEntry and t0.Series = @TargetSeries  )

    begin

  SET @error = -147002

     SET @error_message = 'Please select the appropriate numbering series from the base document'

  end

end

  

END


Viewing all articles
Browse latest Browse all 3022

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>