SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Field status one-time vendor



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Tue Jul 01, 2008 12:11 pm    Post subject: Field status one-time vendor Reply with quote

It is easy to define via customizing for most fields used in the important transactions FB01 and FB60 whether the field is editable or not.

However, it is not easy to re-obtain this information in a program at runtime, because it is NOT stored in an easily understandable database table, but via unstructured strings.

Read field status settings for one-time vendor block
Code:

FUNCTION z_fieldstatus_cpd_getde.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_LIFNR) TYPE LIFNR OPTIONAL
*" VALUE(I_KUNNR) TYPE KUNNR OPTIONAL
*" TABLES
*" T_FIELDS STRUCTURE COBLF
*" EXCEPTIONS
*" DOUBLE_ENTRY
*" PARTNER_NOT_FOUND
*"----------------------------------------------------------------------
  TABLES: t077k, lfa1, kna1.

  TYPES: BEGIN OF lty_fields,
  field TYPE fieldname,
  offset(2),
  END OF lty_fields.
  DATA: lt_fields TYPE TABLE OF lty_fields WITH HEADER LINE.

  DATA: l_ktogr TYPE ktogr.

  DATA: fausw(120).

  DATA: l_partner LIKE lfa1-lifnr.

 

  REFRESH t_fields.

  IF NOT i_lifnr IS INITIAL AND NOT i_kunnr IS INITIAL.
    RAISE double_entry.
  ENDIF.

  IF i_lifnr IS INITIAL AND i_kunnr IS INITIAL.
    EXIT.
  ENDIF.

  IF NOT i_lifnr IS INITIAL.
    l_partner = i_lifnr.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = l_partner
      IMPORTING
        output = l_partner.
    .

    SELECT SINGLE * FROM lfa1 WHERE lifnr = l_partner.
    IF sy-subrc NE 0.
      RAISE partner_not_found.
    ENDIF.

    l_ktogr = lfa1-ktock.
  ELSE.
    l_partner = i_kunnr.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = l_partner
      IMPORTING
        output = l_partner.
    SELECT SINGLE * FROM kna1 WHERE kunnr = l_partner.
    IF sy-subrc NE 0.
      RAISE partner_not_found.
    ENDIF.
    l_ktogr = kna1-ktocd.
  ENDIF.

 


  SELECT SINGLE * FROM t077k
  WHERE ktokk = l_ktogr.

  fausw(40) = t077k-fausa.
  fausw+40(40) = t077k-faus1.
  fausw+80(40) = t077k-faus2.

  PERFORM fill_fields TABLES lt_fields.

  DATA: l_faus(1).

  LOOP AT lt_fields.

    t_fields-fdnam = lt_fields-field.

    IF l_ktogr IS INITIAL.
      t_fields-required = 0.
      t_fields-input = 1.

    ELSE.

      l_faus = fausw+lt_fields-offset(1).

 

      CASE l_faus.
        WHEN '+'.
          t_fields-required = 1.
          t_fields-input = 1.

        WHEN '.'.
          t_fields-required = 0.
          t_fields-input = 1.

        WHEN '*'.
          t_fields-required = 0.
          t_fields-input = 0.
        WHEN '-'.
          t_fields-required = 0.
          t_fields-input = 0.
      ENDCASE.
    ENDIF.
    APPEND t_fields.
  ENDLOOP.
ENDFUNCTION.
*---------------------------------------------------------------------*
* FORM fill_fields *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> LT_FIELDS *
*---------------------------------------------------------------------*
FORM fill_fields TABLES lt_fields.
  TYPES: BEGIN OF llty_fields,
  field TYPE fieldname,
  offset(2),
  END OF llty_fields.
  DATA: llt_fields TYPE TABLE OF llty_fields WITH HEADER LINE.

  llt_fields-field = 'BSEC-ANRED'.
  llt_fields-offset = 2.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-SPRAS'.
  llt_fields-offset = 14.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-NAME1'.
  llt_fields-offset = 1.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-NAME2'.
  llt_fields-offset = 4.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-NAME3'.
  llt_fields-offset = 5.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-NAME4'.
  llt_fields-offset = 5.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STRAS'.
  llt_fields-offset = 7.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-PFACH'.
  llt_fields-offset = 15.
  APPEND llt_fields.

 


  llt_fields-field = 'BSEC-PSTL2'.
  llt_fields-offset = 16.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-ORT01'.
  llt_fields-offset = 6.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-PSTLZ'.
  llt_fields-offset = 6.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-LAND1'.
  llt_fields-offset = 31.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-REGIO'.
  llt_fields-offset = 9.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-BANKL'.
  llt_fields-offset = 30.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-BANKS'.
  llt_fields-offset = 30.
  APPEND llt_fields.


  llt_fields-field = 'BSEC-BANKN'.
  llt_fields-offset = 30.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-BKONT'.
  llt_fields-offset = 30.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-BKREF'.
  llt_fields-offset = 30.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-DTAWS'.
  llt_fields-offset = 34.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STCEG'.
  llt_fields-offset = 24.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-DTAMS'.
  llt_fields-offset = 34.
  APPEND llt_fields.

 

  llt_fields-field = 'BSEC-STCD1'.
  llt_fields-offset = 19.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-FITYP'.
  llt_fields-offset = 61.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STCD2'.
  llt_fields-offset = 41.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STCDT'.
  llt_fields-offset = 61.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STCD3'.
  llt_fields-offset = 63.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STKZN'.
  llt_fields-offset = 43.
  APPEND llt_fields.


  llt_fields-field = 'BSEC-STCD4'.
  llt_fields-offset = 64.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STKZA'.
  llt_fields-offset = 20.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-J_1KFTBUS'.
  llt_fields-offset = 55.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-STKZU'.
  llt_fields-offset = 42.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-J_1KFTIND'.
  llt_fields-offset = 55.
  APPEND llt_fields.

  llt_fields-field = 'BSEC-J_1KFREPRE'.
  llt_fields-offset = 55.
  APPEND llt_fields.


  LOOP AT llt_fields.
    llt_fields-offset = llt_fields-offset - 1.
    MODIFY llt_fields INDEX sy-tabix.
  ENDLOOP.


  lt_fields[] = llt_fields[].
ENDFORM.                    "fill_fields


Read field status settings for account assignment block
Code:

FUNCTION z_fieldstatus_getdetail.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_BSCHL) TYPE BSCHL
*" VALUE(I_BUKRS) TYPE BUKRS
*" VALUE(I_SAKNR) TYPE SAKNR
*" TABLES
*" T_COBLF STRUCTURE COBLF
*" T_FIELDS STRUCTURE TCOBF OPTIONAL
*" EXCEPTIONS
*" ERROR_MESSAGE
*"----------------------------------------------------------------------
***
* liefert Feldstatus in Liste t_coblf:
* Feldname (DDIC) nicht in der Liste -> Feld ausgeblendet
* Feldname (DDIC) in der Liste -> Feld eingabebereit
* required = 1:
* Mussfeld;
* required = 0: kein Mussfeld
* active = 0: Feld ausgblendet
* Als Hilfstabelle wird die gesamte Feldliste der Felder (t_fields)
* ausgegeben,
* deren Eingabebereitschaft im Customizing steht

  DATA: ls_faus1 LIKE tbsl-faus1.
  DATA: ls_faus2 LIKE tbsl-faus2.
* Feldstatus holen
  CALL FUNCTION 'FI_FIELD_SELECTION_DETERMINE'
    EXPORTING
      i_bschl     = i_bschl
      i_bukrs     = i_bukrs
      i_saknr     = i_saknr
    IMPORTING
      e_faus1     = ls_faus1
      e_faus2     = ls_faus2
    EXCEPTIONS
      customizing = 1
      OTHERS      = 2.
  IF sy-subrc <> 0.
    MESSAGE a613(/ssc/comon).
  ENDIF.
  DATA lv_char.
  DATA int_coblf LIKE coblf OCCURS 0 WITH HEADER LINE.
  DATA p_cobl LIKE cobl.
  DATA: dummy_ktosl LIKE bseg-ktosl.

  PERFORM kontierungsblock_ermitteln(sapff001)
  TABLES int_coblf
  USING lv_char(1)
  ls_faus1 ls_faus2 dummy_ktosl.
  t_coblf[] = int_coblf[].


  SELECT * FROM tcobf INTO TABLE t_fields.

ENDFUNCTION.


Source: http: //www.4abp.com/pages/en/home/code-examples.php?lang=EN
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.