I PURCHASEREQUISITIONTP: Unterschied zwischen den Versionen

Aus SAP Wiki ツ
M1ch3lde (Diskussion | Beiträge)
Die Seite wurde neu angelegt: „Kategorie:Behavior Definitionen und Implementierungen === Bestellanforderung anlegen === <syntaxhighlight line copy> </syntaxhighlight> === Bestellanforderung lesen === <syntaxhighlight line copy> </syntaxhighlight> === Bestellanforderung ändern === <syntaxhighlight line copy> </syntaxhighlight> === Bestellanforderungsposition als gelöscht markieren === <syntaxhighlight line copy> DATA lt_delete TYPE TABLE FOR UPDATE I_PurchaseRequisitionTP\…“
 
M1ch3lde (Diskussion | Beiträge)
Zeile 10: Zeile 10:
</syntaxhighlight>
</syntaxhighlight>


=== Bestellanforderung ändern ===
=== Bestellanforderungsposition ändern ===


<syntaxhighlight line copy>
<syntaxhighlight line copy>
DATA lt_read_result  TYPE TABLE FOR READ RESULT yc_prmonitor\\prmonitor.
    DATA ls_read_failed  TYPE RESPONSE FOR FAILED EARLY yc_prmonitor.
    DATA ls_read_reported TYPE RESPONSE FOR REPORTED EARLY yc_prmonitor.


    read( EXPORTING keys    = CORRESPONDING #( keys )
          CHANGING  result  = lt_read_result
                    failed  = ls_read_failed
                    reported = ls_read_reported ).
    IF ls_read_failed IS NOT INITIAL.
      APPEND VALUE #( %msg = new_message( id      = ycl_p2p_prmonitor_constants=>cv_message_class
                                          number  = '005'
                                          severity = if_abap_behv_message=>severity-error ) )
            TO reported-prmonitor.
      RETURN.
    ENDIF.
    MODIFY ENTITIES OF i_purchaserequisitiontp
          ENTITY purchaserequisitionitem UPDATE FROM VALUE #(
              ( PurchaseRequisition            = keys[ 1 ]-PurchaseRequisition
                PurchaseRequisitionItem        = keys[ 1 ]-PurchaseRequisitionItem
                %data-RequestedQuantity        = keys[ 1 ]-%param-RequestedQuantity
                %data-DeliveryDate              = keys[ 1 ]-%param-DeliveryDate
                %data-Plant    = keys[ 1 ]-%param-PLant
                %data-StorageLocation          = keys[ 1 ]-%param-StorageLocation
                %data-PurchasingOrganization    = keys[ 1 ]-%param-PurchasingOrganization
                %data-PurchasingGroup          = keys[ 1 ]-%param-PurchasingGroup
                %control-RequestedQuantity      = COND #( WHEN keys[ 1 ]-%param-RequestedQuantity <> lt_read_result[ 1 ]-RequestedQuantity
                                                          THEN if_abap_behv=>mk-on )
                %control-DeliveryDate          = COND #( WHEN keys[ 1 ]-%param-DeliveryDate <> lt_read_result[ 1 ]-DeliveryDate
                                                          THEN if_abap_behv=>mk-on )
                %control-Plant          = COND #( WHEN keys[ 1 ]-%param-Plant <> lt_read_result[ 1 ]-Plant
                                                          THEN if_abap_behv=>mk-on )
                %control-StorageLocation = COND #( WHEN keys[ 1 ]-%param-StorageLocation <> lt_read_result[ 1 ]-StorageLocation
                                                          THEN if_abap_behv=>mk-on )
                %control-PurchasingOrganization = COND #( WHEN keys[ 1 ]-%param-PurchasingOrganization <> lt_read_result[ 1 ]-PurchasingOrganization
                                                          THEN if_abap_behv=>mk-on )
                %control-PurchasingGroup        = COND #( WHEN keys[ 1 ]-%param-PurchasingGroup <> lt_read_result[ 1 ]-PurchasingGroup
                                                          THEN if_abap_behv=>mk-on ) ) )
          REPORTED DATA(ls_update_reported)
          FAILED  DATA(ls_update_failed)
          " TODO: variable is assigned but never used (ABAP cleaner)
          MAPPED  DATA(ls_update_mappend).
    IF ls_update_failed IS INITIAL.
      APPEND VALUE #( %msg = new_message( id      = ycl_p2p_prmonitor_constants=>cv_message_class
                                          number  = '046'
                                          severity = if_abap_behv_message=>severity-success ) )
            TO reported-prmonitor.
      APPEND VALUE #( %cid                    = keys[ 1 ]-%cid
                      PurchaseRequisition    = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem ) TO mapped-prmonitor.
      RETURN.
    ELSE.
      IF ls_update_reported-PurchaseRequisitionItem IS NOT INITIAL.
        APPEND VALUE #(
            %msg = new_message_with_text(
                      severity = ls_update_reported-PurchaseRequisitionItem[ 1 ]-%msg->m_severity
                      text    = ls_update_reported-PurchaseRequisitionItem[ 1 ]-%msg->if_message~get_text( ) ) )
              TO reported-prmonitor.
      ENDIF.
      APPEND VALUE #( PurchaseRequisition    = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem )
            TO failed-prmonitor.
    ENDIF.
</syntaxhighlight>
</syntaxhighlight>



Version vom 4. Juni 2025, 10:19 Uhr

Bestellanforderung anlegen

Bestellanforderung lesen

Bestellanforderungsposition ändern

 DATA lt_read_result   TYPE TABLE FOR READ RESULT yc_prmonitor\\prmonitor.
    DATA ls_read_failed   TYPE RESPONSE FOR FAILED EARLY yc_prmonitor.
    DATA ls_read_reported TYPE RESPONSE FOR REPORTED EARLY yc_prmonitor.

    read( EXPORTING keys     = CORRESPONDING #( keys )
          CHANGING  result   = lt_read_result
                    failed   = ls_read_failed
                    reported = ls_read_reported ).

    IF ls_read_failed IS NOT INITIAL.
      APPEND VALUE #( %msg = new_message( id       = ycl_p2p_prmonitor_constants=>cv_message_class
                                          number   = '005'
                                          severity = if_abap_behv_message=>severity-error ) )
             TO reported-prmonitor.
      RETURN.
    ENDIF.

    MODIFY ENTITIES OF i_purchaserequisitiontp
           ENTITY purchaserequisitionitem UPDATE FROM VALUE #(
               ( PurchaseRequisition             = keys[ 1 ]-PurchaseRequisition
                 PurchaseRequisitionItem         = keys[ 1 ]-PurchaseRequisitionItem
                 %data-RequestedQuantity         = keys[ 1 ]-%param-RequestedQuantity
                 %data-DeliveryDate              = keys[ 1 ]-%param-DeliveryDate
                 %data-Plant    = keys[ 1 ]-%param-PLant
                 %data-StorageLocation           = keys[ 1 ]-%param-StorageLocation
                 %data-PurchasingOrganization    = keys[ 1 ]-%param-PurchasingOrganization
                 %data-PurchasingGroup           = keys[ 1 ]-%param-PurchasingGroup
                 %control-RequestedQuantity      = COND #( WHEN keys[ 1 ]-%param-RequestedQuantity <> lt_read_result[ 1 ]-RequestedQuantity
                                                           THEN if_abap_behv=>mk-on )
                 %control-DeliveryDate           = COND #( WHEN keys[ 1 ]-%param-DeliveryDate <> lt_read_result[ 1 ]-DeliveryDate
                                                           THEN if_abap_behv=>mk-on )
                 %control-Plant           = COND #( WHEN keys[ 1 ]-%param-Plant <> lt_read_result[ 1 ]-Plant
                                                           THEN if_abap_behv=>mk-on )
                 %control-StorageLocation = COND #( WHEN keys[ 1 ]-%param-StorageLocation <> lt_read_result[ 1 ]-StorageLocation
                                                           THEN if_abap_behv=>mk-on )
                 %control-PurchasingOrganization = COND #( WHEN keys[ 1 ]-%param-PurchasingOrganization <> lt_read_result[ 1 ]-PurchasingOrganization
                                                           THEN if_abap_behv=>mk-on )
                 %control-PurchasingGroup        = COND #( WHEN keys[ 1 ]-%param-PurchasingGroup <> lt_read_result[ 1 ]-PurchasingGroup
                                                           THEN if_abap_behv=>mk-on ) ) )
           REPORTED DATA(ls_update_reported)
           FAILED   DATA(ls_update_failed)
           " TODO: variable is assigned but never used (ABAP cleaner)
           MAPPED   DATA(ls_update_mappend).

    IF ls_update_failed IS INITIAL.
      APPEND VALUE #( %msg = new_message( id       = ycl_p2p_prmonitor_constants=>cv_message_class
                                          number   = '046'
                                          severity = if_abap_behv_message=>severity-success ) )
             TO reported-prmonitor.

      APPEND VALUE #( %cid                    = keys[ 1 ]-%cid
                      PurchaseRequisition     = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem ) TO mapped-prmonitor.

      RETURN.
    ELSE.

      IF ls_update_reported-PurchaseRequisitionItem IS NOT INITIAL.
        APPEND VALUE #(
            %msg = new_message_with_text(
                       severity = ls_update_reported-PurchaseRequisitionItem[ 1 ]-%msg->m_severity
                       text     = ls_update_reported-PurchaseRequisitionItem[ 1 ]-%msg->if_message~get_text( ) ) )
               TO reported-prmonitor.
      ENDIF.

      APPEND VALUE #( PurchaseRequisition     = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem )
             TO failed-prmonitor.

    ENDIF.

Bestellanforderungsposition als gelöscht markieren

DATA lt_delete TYPE TABLE FOR UPDATE I_PurchaseRequisitionTP\\PurchaseRequisitionItem.

    lt_delete = CORRESPONDING #( keys ).

    LOOP AT lt_delete ASSIGNING FIELD-SYMBOL(<ls_delete>).
      <ls_delete>-IsDeleted = abap_true.
      <ls_delete>-%data-IsDeleted = abap_true.
      <ls_delete>-%control-IsDeleted = if_abap_behv=>mk-on.
    ENDLOOP.

    MODIFY ENTITIES OF i_purchaserequisitiontp
           ENTITY PurchaseRequisitionItem UPDATE FROM lt_delete
           MAPPED DATA(ls_mapped) REPORTED DATA(ls_reported) FAILED DATA(ls_failed).

    IF ls_failed IS INITIAL.
           APPEND VALUE #( %msg = new_message( id       = ycl_p2p_prmonitor_constants=>cv_message_class
                                               number   = '049'
                                               severity = if_abap_behv_message=>severity-success ) )
             TO reported-prmonitor.
    ELSE.
      IF ls_reported-PurchaseRequisitionItem IS NOT INITIAL.
        APPEND VALUE #( %msg = new_message_with_text(
                                   severity = ls_reported-PurchaseRequisition[ 1 ]-%msg->m_severity
                                   text     = ls_reported-PurchaseRequisition[ 1 ]-%msg->if_message~get_text( ) ) )
               TO reported-prmonitor.
      ENDIF.

      IF ls_reported-PurchaseRequisitionItem IS NOT INITIAL.
        LOOP AT ls_reported-PurchaseRequisitionItem ASSIGNING FIELD-SYMBOL(<ls_rep_po_item>).
          APPEND VALUE #(
              %msg = new_message_with_text(
                         severity = ls_reported-PurchaseRequisitionItem[ sy-tabix ]-%msg->m_severity
                         text     = ls_reported-PurchaseRequisitionItem[ sy-tabix ]-%msg->if_message~get_text( ) ) )
                 TO reported-prmonitor.
        ENDLOOP.
      ENDIF.

      APPEND VALUE #( PurchaseRequisition     = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem )
             TO failed-prmonitor.
    ENDIF.

    LOOP AT keys ASSIGNING FIELD-SYMBOL(<ls_keys>).
        APPEND VALUE #( "%cid                    = <ls_keys>-%cid
                        PurchaseRequisition     = <ls_keys>-PurchaseRequisition
                        PurchaseRequisitionItem = <ls_keys>-PurchaseRequisitionItem ) TO mapped-prmonitor.
    ENDLOOP.

Bestellanforderungsposition Löschkennzeichen zurücknehmen

    DATA lt_undo TYPE TABLE FOR UPDATE I_PurchaseRequisitionTP\\PurchaseRequisitionItem.

    lt_undo = CORRESPONDING #( keys ).

    LOOP AT lt_undo ASSIGNING FIELD-SYMBOL(<ls_undo>).
      <ls_undo>-IsDeleted = abap_false.
      <ls_undo>-%data-IsDeleted = abap_false.
      <ls_undo>-%control-IsDeleted = if_abap_behv=>mk-on.
    ENDLOOP.

    MODIFY ENTITIES OF i_purchaserequisitiontp
           ENTITY PurchaseRequisitionItem UPDATE FROM lt_undo
           MAPPED DATA(ls_mapped) REPORTED DATA(ls_reported) FAILED DATA(ls_failed).
    IF ls_failed IS INITIAL.
      APPEND VALUE #( %msg = new_message( id       = ycl_p2p_prmonitor_constants=>cv_message_class
                                          number   = '044'
                                          severity = if_abap_behv_message=>severity-success ) )
             TO reported-prmonitor.
    ELSE.
      IF ls_reported-PurchaseRequisitionItem IS NOT INITIAL.
        APPEND VALUE #( %msg = new_message_with_text(
                                   severity = ls_reported-PurchaseRequisition[ 1 ]-%msg->m_severity
                                   text     = ls_reported-PurchaseRequisition[ 1 ]-%msg->if_message~get_text( ) ) )
               TO reported-prmonitor.
      ENDIF.

      IF ls_reported-PurchaseRequisitionItem IS NOT INITIAL.
        " TODO: variable is assigned but never used (ABAP cleaner)
        LOOP AT ls_reported-PurchaseRequisitionItem ASSIGNING FIELD-SYMBOL(<ls_rep_po_item>).
          APPEND VALUE #(
              %msg = new_message_with_text(
                         severity = ls_reported-PurchaseRequisitionItem[ sy-tabix ]-%msg->m_severity
                         text     = ls_reported-PurchaseRequisitionItem[ sy-tabix ]-%msg->if_message~get_text( ) ) )
                 TO reported-prmonitor.
        ENDLOOP.
      ENDIF.

      APPEND VALUE #( PurchaseRequisition     = keys[ 1 ]-PurchaseRequisition
                      PurchaseRequisitionItem = keys[ 1 ]-PurchaseRequisitionItem )
             TO failed-prmonitor.
    ENDIF.

    LOOP AT keys ASSIGNING FIELD-SYMBOL(<ls_keys>).
        APPEND VALUE #( %cid                    = <ls_keys>-%cid
                        PurchaseRequisition     = <ls_keys>-PurchaseRequisition
                        PurchaseRequisitionItem = <ls_keys>-PurchaseRequisitionItem ) TO mapped-prmonitor.
    ENDLOOP.